kiarina-utils-common 1.35.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,35 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.so
5
+ *.egg-info/
6
+ dist/
7
+ build/
8
+ .ruff_cache/
9
+ .mypy_cache/
10
+ .pytest_cache/
11
+ .coverage
12
+ coverage.xml
13
+ htmlcov/
14
+
15
+ # uv
16
+ .uv_cache/
17
+
18
+ # Virtual environments & config
19
+ .venv/
20
+ .env
21
+
22
+ # OS
23
+ .DS_Store
24
+
25
+ # Project specific
26
+ *.log
27
+ tmp/
28
+ packages/*/test_settings.yaml
29
+
30
+ # Test data
31
+ tests/data/large/
32
+
33
+ # mise tasks (always include)
34
+ !mise-tasks/
35
+ !mise-tasks/**
@@ -0,0 +1,7 @@
1
+ {
2
+ "python.testing.pytestArgs": [
3
+ "tests"
4
+ ],
5
+ "python.testing.unittestEnabled": false,
6
+ "python.testing.pytestEnabled": true
7
+ }
@@ -0,0 +1,294 @@
1
+ # Changelog
2
+
3
+ All notable changes to the kiarina-utils-common package will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [1.35.0] - 2026-01-31
11
+
12
+ ### Changed
13
+ - No changes
14
+
15
+ ## [1.34.0] - 2026-01-31
16
+
17
+ ### Changed
18
+ - No changes
19
+
20
+ ## [1.33.1] - 2026-01-31
21
+
22
+ ### Changed
23
+ - No changes
24
+
25
+ ## [1.33.0] - 2026-01-31
26
+
27
+ ### Changed
28
+ - No changes
29
+
30
+ ## [1.32.0] - 2026-01-30
31
+
32
+ ### Changed
33
+ - No changes
34
+
35
+ ## [1.31.1] - 2026-01-29
36
+
37
+ ### Changed
38
+ - No changes
39
+
40
+ ## [1.31.0] - 2026-01-29
41
+
42
+ ### Changed
43
+ - No changes
44
+
45
+ ## [1.30.0] - 2026-01-27
46
+
47
+ ### Changed
48
+ - No changes
49
+
50
+ ## [1.29.0] - 2026-01-16
51
+
52
+ ### Changed
53
+ - No changes
54
+
55
+ ## [1.28.0] - 2026-01-16
56
+
57
+ ### Changed
58
+ - No changes
59
+
60
+ ## [1.27.0] - 2026-01-12
61
+
62
+ ### Changed
63
+ - No changes
64
+
65
+ ## [1.26.0] - 2026-01-09
66
+
67
+ ### Changed
68
+ - No changes
69
+
70
+ ## [1.25.1] - 2026-01-08
71
+
72
+ ### Changed
73
+ - No changes
74
+
75
+ ## [1.25.0] - 2026-01-08
76
+
77
+ ### Changed
78
+ - No changes
79
+
80
+ ## [1.24.0] - 2026-01-08
81
+
82
+ ### Changed
83
+ - No changes
84
+
85
+ ## [1.23.0] - 2026-01-06
86
+
87
+ ### Changed
88
+ - No changes
89
+
90
+ ## [1.22.1] - 2026-01-06
91
+
92
+ ### Changed
93
+ - No changes
94
+
95
+ ## [1.22.0] - 2026-01-05
96
+
97
+ ### Changed
98
+ - No changes
99
+
100
+ ## [1.21.1] - 2026-01-05
101
+
102
+ ### Changed
103
+ - No changes
104
+
105
+ ## [1.21.0] - 2025-12-30
106
+
107
+ ### Changed
108
+ - No changes
109
+
110
+ ## [1.20.1] - 2025-12-25
111
+
112
+ ### Changed
113
+ - No changes
114
+
115
+ ## [1.20.0] - 2025-12-19
116
+
117
+ ### Changed
118
+ - No changes
119
+
120
+ ## [1.19.0] - 2025-12-19
121
+
122
+ ### Changed
123
+ - No changes
124
+
125
+ ## [1.18.2] - 2025-12-17
126
+
127
+ ### Changed
128
+ - No changes
129
+
130
+ ## [1.18.1] - 2025-12-16
131
+
132
+ ### Changed
133
+ - No changes
134
+
135
+ ## [1.18.0] - 2025-12-16
136
+
137
+ ### Changed
138
+ - No changes
139
+
140
+ ## [1.17.0] - 2025-12-15
141
+
142
+ ### Changed
143
+ - No changes
144
+
145
+ ## [1.16.0] - 2025-12-15
146
+
147
+ ### Changed
148
+ - No changes
149
+
150
+ ## [1.15.1] - 2025-12-14
151
+
152
+ ### Changed
153
+ - No changes
154
+
155
+ ## [1.15.0] - 2025-12-13
156
+
157
+ ### Changed
158
+ - No changes
159
+
160
+ ## [1.14.0] - 2025-12-13
161
+
162
+ ### Changed
163
+ - No changes
164
+
165
+ ## [1.13.0] - 2025-12-09
166
+
167
+ ### Changed
168
+ - No changes
169
+
170
+ ## [1.12.0] - 2025-12-05
171
+
172
+ ### Changed
173
+ - No changes
174
+
175
+ ## [1.11.2] - 2025-12-02
176
+
177
+ ### Added
178
+ - `ConfigStr` type alias for configuration string format documentation
179
+
180
+ ## [1.11.1] - 2025-12-01
181
+
182
+ ### Changed
183
+ - No changes
184
+
185
+ ## [1.11.0] - 2025-12-01
186
+
187
+ ### Changed
188
+ - No changes
189
+
190
+ ## [1.10.0] - 2025-12-01
191
+
192
+ ### Added
193
+ - `import_object` function for dynamic object importing from import paths (useful for plugin systems)
194
+
195
+ ## [1.9.0] - 2025-11-26
196
+
197
+ ### Changed
198
+ - No changes
199
+
200
+ ## [1.8.0] - 2025-10-24
201
+
202
+ ### Changed
203
+ - No changes
204
+
205
+ ## [1.7.0] - 2025-10-21
206
+
207
+ ### Changed
208
+ - No changes
209
+
210
+ ## [1.6.3] - 2025-10-13
211
+
212
+ ### Changed
213
+ - No changes
214
+
215
+ ## [1.6.2] - 2025-10-10
216
+
217
+ ### Changed
218
+ - No changes
219
+
220
+ ## [1.6.1] - 2025-10-10
221
+
222
+ ### Changed
223
+ - No changes
224
+
225
+ ## [1.6.0] - 2025-10-10
226
+
227
+ ### Changed
228
+ - No changes
229
+
230
+ ## [1.5.0] - 2025-10-10
231
+
232
+ ### Changed
233
+ - No changes
234
+
235
+ ## [1.4.0] - 2025-10-09
236
+
237
+ ### Changed
238
+ - No changes
239
+
240
+ ## [1.3.0] - 2025-10-05
241
+
242
+ ### Changed
243
+ - No changes
244
+
245
+ ## [1.2.0] - 2025-09-25
246
+
247
+ ### Changed
248
+ - No changes
249
+
250
+ ## [1.1.1] - 2025-09-11
251
+
252
+ ### Changed
253
+ - No changes
254
+
255
+ ## [1.1.0] - 2025-09-11
256
+
257
+ ### Changed
258
+ - No changes
259
+
260
+ ## [1.0.1] - 2025-09-11
261
+
262
+ ### Changed
263
+ - No changes - version bump for consistency with other packages
264
+
265
+ ## [1.0.0] - 2025-09-09
266
+
267
+ ### Added
268
+ - Comprehensive README.md with usage examples and API documentation
269
+ - Enhanced pyproject.toml with proper metadata, classifiers, and project URLs
270
+ - CHANGELOG.md for tracking version changes
271
+
272
+ ### Changed
273
+ - Improved package documentation and metadata
274
+
275
+ ## [0.1.0] - 2025-01-09
276
+
277
+ ### Added
278
+ - Initial release of kiarina-utils-common
279
+ - `parse_config_string` function for parsing configuration strings
280
+ - Support for nested keys using dot notation
281
+ - Support for array indices in configuration strings
282
+ - Automatic type conversion (bool, int, float, str)
283
+ - Flag support (keys without values)
284
+ - Customizable separators for different parsing needs
285
+ - Comprehensive test suite with pytest
286
+ - Type hints and py.typed marker for full typing support
287
+
288
+ ### Features
289
+ - Parse configuration strings like `"cache.enabled:true,db.port:5432"`
290
+ - Support for nested structures: `{"cache": {"enabled": True}, "db": {"port": 5432}}`
291
+ - Array index support: `"items.0:first,items.1:second"` → `{"items": ["first", "second"]}`
292
+ - Flag functionality: `"debug,verbose"` → `{"debug": None, "verbose": None}`
293
+ - Custom separators: configurable item, key-value, and nested separators
294
+ - Automatic type detection and conversion for common data types
@@ -0,0 +1,195 @@
1
+ Metadata-Version: 2.4
2
+ Name: kiarina-utils-common
3
+ Version: 1.35.0
4
+ Summary: Common utility functions for the kiarina namespace packages
5
+ Project-URL: Homepage, https://github.com/kiarina/kiarina-python
6
+ Project-URL: Repository, https://github.com/kiarina/kiarina-python
7
+ Project-URL: Issues, https://github.com/kiarina/kiarina-python/issues
8
+ Project-URL: Changelog, https://github.com/kiarina/kiarina-python/blob/main/packages/kiarina-utils-common/CHANGELOG.md
9
+ Project-URL: Documentation, https://github.com/kiarina/kiarina-python/tree/main/packages/kiarina-utils-common#readme
10
+ Author-email: kiarina <kiarinadawa@gmail.com>
11
+ Maintainer-email: kiarina <kiarinadawa@gmail.com>
12
+ License-Expression: MIT
13
+ Keywords: common,config,parser,utilities
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Topic :: Utilities
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.12
24
+ Description-Content-Type: text/markdown
25
+
26
+ # kiarina-utils-common
27
+
28
+ [![PyPI version](https://badge.fury.io/py/kiarina-utils-common.svg)](https://badge.fury.io/py/kiarina-utils-common)
29
+ [![Python](https://img.shields.io/pypi/pyversions/kiarina-utils-common.svg)](https://pypi.org/project/kiarina-utils-common/)
30
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
31
+
32
+ Common utility functions for the kiarina namespace packages.
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ pip install kiarina-utils-common
38
+ ```
39
+
40
+ ## Features
41
+
42
+ ### Dynamic Object Import
43
+
44
+ Import objects (classes, functions, constants) dynamically from import paths. Useful for plugin systems and dynamic loading scenarios.
45
+
46
+ ```python
47
+ from kiarina.utils.common import import_object
48
+
49
+ # Import a function
50
+ parse_fn = import_object("kiarina.utils.common:parse_config_string")
51
+ result = parse_fn("key:value")
52
+
53
+ # Import a class
54
+ MyClass = import_object("myapp.plugins:MyPlugin")
55
+ instance = MyClass()
56
+
57
+ # Import with type hints for better IDE support
58
+ from typing import Callable
59
+ parser: Callable = import_object("kiarina.utils.common:parse_config_string")
60
+ ```
61
+
62
+ ### Configuration String Parser
63
+
64
+ Parse configuration strings into nested dictionaries with automatic type conversion.
65
+
66
+ ```python
67
+ from kiarina.utils.common import parse_config_string
68
+
69
+ # Basic usage
70
+ config = parse_config_string("cache.enabled:true,db.port:5432")
71
+ # Result: {"cache": {"enabled": True}, "db": {"port": 5432}}
72
+
73
+ # Flag support (no value)
74
+ config = parse_config_string("debug,verbose,cache.enabled:true")
75
+ # Result: {"debug": None, "verbose": None, "cache": {"enabled": True}}
76
+
77
+ # Array indices support
78
+ config = parse_config_string("items.0:first,items.1:second")
79
+ # Result: {"items": ["first", "second"]}
80
+
81
+ # Custom separators
82
+ config = parse_config_string(
83
+ "key1=val1;key2.sub=42",
84
+ separator=";",
85
+ key_value_separator="="
86
+ )
87
+ # Result: {"key1": "val1", "key2": {"sub": 42}}
88
+ ```
89
+
90
+ #### Type Conversion
91
+
92
+ Values are automatically converted to appropriate types:
93
+
94
+ - `"true"`, `"True"` → `bool(True)`
95
+ - `"false"`, `"False"` → `bool(False)`
96
+ - Numeric strings (`"1"`, `"0"`, `"-5"`, `"3.14"`) → `int` or `float`
97
+ - Other strings → `str`
98
+
99
+ #### Nested Keys
100
+
101
+ Use dot notation for nested structures:
102
+
103
+ ```python
104
+ config = parse_config_string("database.host:localhost,database.port:5432")
105
+ # Result: {"database": {"host": "localhost", "port": 5432}}
106
+ ```
107
+
108
+ #### Array Indices
109
+
110
+ Use numeric keys for array structures:
111
+
112
+ ```python
113
+ config = parse_config_string("users.0.name:Alice,users.0.age:30,users.1.name:Bob")
114
+ # Result: {"users": [{"name": "Alice", "age": 30}, {"name": "Bob"}]}
115
+ ```
116
+
117
+ ## API Reference
118
+
119
+ ### `import_object(import_path)`
120
+
121
+ Import and return an object from an import path.
122
+
123
+ **Parameters:**
124
+ - `import_path` (str): Import path in the format `'module_name:object_name'`
125
+ - Example: `'kiarina.utils.common:parse_config_string'`
126
+
127
+ **Returns:**
128
+ - The imported object (class, function, or any other object)
129
+
130
+ **Raises:**
131
+ - `ValueError`: If import_path format is invalid
132
+ - `ImportError`: If the module cannot be imported
133
+ - `AttributeError`: If the object doesn't exist in the module
134
+
135
+ **Examples:**
136
+
137
+ ```python
138
+ # Import a function
139
+ parse_fn = import_object('kiarina.utils.common:parse_config_string')
140
+ result = parse_fn('key:value')
141
+
142
+ # Import a class
143
+ MyClass = import_object('myapp.plugins:MyPlugin')
144
+ instance = MyClass()
145
+
146
+ # Use with type hints
147
+ from typing import Callable
148
+ parser: Callable = import_object('kiarina.utils.common:parse_config_string')
149
+ ```
150
+
151
+ ### `parse_config_string(config_str, *, separator=",", key_value_separator=":", nested_separator=".")`
152
+
153
+ Parse configuration string into nested dictionary.
154
+
155
+ **Parameters:**
156
+ - `config_str` (str): Configuration string to parse
157
+ - `separator` (str, optional): Item separator. Default: `","`
158
+ - `key_value_separator` (str, optional): Key-value separator. Default: `":"`
159
+ - `nested_separator` (str, optional): Nested key separator. Default: `"."`
160
+
161
+ **Returns:**
162
+ - `dict[str, Any]`: Parsed configuration dictionary
163
+
164
+ **Examples:**
165
+
166
+ ```python
167
+ # Basic usage
168
+ parse_config_string("key1:value1,key2:value2")
169
+ # {"key1": "value1", "key2": "value2"}
170
+
171
+ # Nested keys
172
+ parse_config_string("cache.enabled:true,db.port:5432")
173
+ # {"cache": {"enabled": True}, "db": {"port": 5432}}
174
+
175
+ # Flags (no value)
176
+ parse_config_string("debug,verbose")
177
+ # {"debug": None, "verbose": None}
178
+
179
+ # Custom separators
180
+ parse_config_string("a=1;b=2", separator=";", key_value_separator="=")
181
+ # {"a": 1, "b": 2}
182
+ ```
183
+
184
+ ## License
185
+
186
+ This project is licensed under the MIT License - see the [LICENSE](../../LICENSE) file for details.
187
+
188
+ ## Contributing
189
+
190
+ This is a personal project by kiarina. While issues and pull requests are welcome, please note that this is primarily developed for personal use.
191
+
192
+ ## Related Packages
193
+
194
+ - [kiarina-utils-file](../kiarina-utils-file/): File operation utilities
195
+ - [kiarina-llm](../kiarina-llm/): LLM-related utilities
@@ -0,0 +1,170 @@
1
+ # kiarina-utils-common
2
+
3
+ [![PyPI version](https://badge.fury.io/py/kiarina-utils-common.svg)](https://badge.fury.io/py/kiarina-utils-common)
4
+ [![Python](https://img.shields.io/pypi/pyversions/kiarina-utils-common.svg)](https://pypi.org/project/kiarina-utils-common/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ Common utility functions for the kiarina namespace packages.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pip install kiarina-utils-common
13
+ ```
14
+
15
+ ## Features
16
+
17
+ ### Dynamic Object Import
18
+
19
+ Import objects (classes, functions, constants) dynamically from import paths. Useful for plugin systems and dynamic loading scenarios.
20
+
21
+ ```python
22
+ from kiarina.utils.common import import_object
23
+
24
+ # Import a function
25
+ parse_fn = import_object("kiarina.utils.common:parse_config_string")
26
+ result = parse_fn("key:value")
27
+
28
+ # Import a class
29
+ MyClass = import_object("myapp.plugins:MyPlugin")
30
+ instance = MyClass()
31
+
32
+ # Import with type hints for better IDE support
33
+ from typing import Callable
34
+ parser: Callable = import_object("kiarina.utils.common:parse_config_string")
35
+ ```
36
+
37
+ ### Configuration String Parser
38
+
39
+ Parse configuration strings into nested dictionaries with automatic type conversion.
40
+
41
+ ```python
42
+ from kiarina.utils.common import parse_config_string
43
+
44
+ # Basic usage
45
+ config = parse_config_string("cache.enabled:true,db.port:5432")
46
+ # Result: {"cache": {"enabled": True}, "db": {"port": 5432}}
47
+
48
+ # Flag support (no value)
49
+ config = parse_config_string("debug,verbose,cache.enabled:true")
50
+ # Result: {"debug": None, "verbose": None, "cache": {"enabled": True}}
51
+
52
+ # Array indices support
53
+ config = parse_config_string("items.0:first,items.1:second")
54
+ # Result: {"items": ["first", "second"]}
55
+
56
+ # Custom separators
57
+ config = parse_config_string(
58
+ "key1=val1;key2.sub=42",
59
+ separator=";",
60
+ key_value_separator="="
61
+ )
62
+ # Result: {"key1": "val1", "key2": {"sub": 42}}
63
+ ```
64
+
65
+ #### Type Conversion
66
+
67
+ Values are automatically converted to appropriate types:
68
+
69
+ - `"true"`, `"True"` → `bool(True)`
70
+ - `"false"`, `"False"` → `bool(False)`
71
+ - Numeric strings (`"1"`, `"0"`, `"-5"`, `"3.14"`) → `int` or `float`
72
+ - Other strings → `str`
73
+
74
+ #### Nested Keys
75
+
76
+ Use dot notation for nested structures:
77
+
78
+ ```python
79
+ config = parse_config_string("database.host:localhost,database.port:5432")
80
+ # Result: {"database": {"host": "localhost", "port": 5432}}
81
+ ```
82
+
83
+ #### Array Indices
84
+
85
+ Use numeric keys for array structures:
86
+
87
+ ```python
88
+ config = parse_config_string("users.0.name:Alice,users.0.age:30,users.1.name:Bob")
89
+ # Result: {"users": [{"name": "Alice", "age": 30}, {"name": "Bob"}]}
90
+ ```
91
+
92
+ ## API Reference
93
+
94
+ ### `import_object(import_path)`
95
+
96
+ Import and return an object from an import path.
97
+
98
+ **Parameters:**
99
+ - `import_path` (str): Import path in the format `'module_name:object_name'`
100
+ - Example: `'kiarina.utils.common:parse_config_string'`
101
+
102
+ **Returns:**
103
+ - The imported object (class, function, or any other object)
104
+
105
+ **Raises:**
106
+ - `ValueError`: If import_path format is invalid
107
+ - `ImportError`: If the module cannot be imported
108
+ - `AttributeError`: If the object doesn't exist in the module
109
+
110
+ **Examples:**
111
+
112
+ ```python
113
+ # Import a function
114
+ parse_fn = import_object('kiarina.utils.common:parse_config_string')
115
+ result = parse_fn('key:value')
116
+
117
+ # Import a class
118
+ MyClass = import_object('myapp.plugins:MyPlugin')
119
+ instance = MyClass()
120
+
121
+ # Use with type hints
122
+ from typing import Callable
123
+ parser: Callable = import_object('kiarina.utils.common:parse_config_string')
124
+ ```
125
+
126
+ ### `parse_config_string(config_str, *, separator=",", key_value_separator=":", nested_separator=".")`
127
+
128
+ Parse configuration string into nested dictionary.
129
+
130
+ **Parameters:**
131
+ - `config_str` (str): Configuration string to parse
132
+ - `separator` (str, optional): Item separator. Default: `","`
133
+ - `key_value_separator` (str, optional): Key-value separator. Default: `":"`
134
+ - `nested_separator` (str, optional): Nested key separator. Default: `"."`
135
+
136
+ **Returns:**
137
+ - `dict[str, Any]`: Parsed configuration dictionary
138
+
139
+ **Examples:**
140
+
141
+ ```python
142
+ # Basic usage
143
+ parse_config_string("key1:value1,key2:value2")
144
+ # {"key1": "value1", "key2": "value2"}
145
+
146
+ # Nested keys
147
+ parse_config_string("cache.enabled:true,db.port:5432")
148
+ # {"cache": {"enabled": True}, "db": {"port": 5432}}
149
+
150
+ # Flags (no value)
151
+ parse_config_string("debug,verbose")
152
+ # {"debug": None, "verbose": None}
153
+
154
+ # Custom separators
155
+ parse_config_string("a=1;b=2", separator=";", key_value_separator="=")
156
+ # {"a": 1, "b": 2}
157
+ ```
158
+
159
+ ## License
160
+
161
+ This project is licensed under the MIT License - see the [LICENSE](../../LICENSE) file for details.
162
+
163
+ ## Contributing
164
+
165
+ This is a personal project by kiarina. While issues and pull requests are welcome, please note that this is primarily developed for personal use.
166
+
167
+ ## Related Packages
168
+
169
+ - [kiarina-utils-file](../kiarina-utils-file/): File operation utilities
170
+ - [kiarina-llm](../kiarina-llm/): LLM-related utilities