Name | kiarina-utils-common JSON |
Version |
1.0.1
JSON |
| download |
home_page | None |
Summary | Common utility functions for the kiarina namespace packages |
upload_time | 2025-09-11 08:52:31 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.12 |
license | MIT |
keywords |
common
config
parser
utilities
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# kiarina-utils-common
[](https://badge.fury.io/py/kiarina-utils-common)
[](https://pypi.org/project/kiarina-utils-common/)
[](https://opensource.org/licenses/MIT)
Common utility functions for the kiarina namespace packages.
## Installation
```bash
pip install kiarina-utils-common
```
## Features
### Configuration String Parser
Parse configuration strings into nested dictionaries with automatic type conversion.
```python
from kiarina.utils.common import parse_config_string
# Basic usage
config = parse_config_string("cache.enabled:true,db.port:5432")
# Result: {"cache": {"enabled": True}, "db": {"port": 5432}}
# Flag support (no value)
config = parse_config_string("debug,verbose,cache.enabled:true")
# Result: {"debug": None, "verbose": None, "cache": {"enabled": True}}
# Array indices support
config = parse_config_string("items.0:first,items.1:second")
# Result: {"items": ["first", "second"]}
# Custom separators
config = parse_config_string(
"key1=val1;key2.sub=42",
separator=";",
key_value_separator="="
)
# Result: {"key1": "val1", "key2": {"sub": 42}}
```
#### Type Conversion
Values are automatically converted to appropriate types:
- `"true"`, `"True"` → `bool(True)`
- `"false"`, `"False"` → `bool(False)`
- Numeric strings (`"1"`, `"0"`, `"-5"`, `"3.14"`) → `int` or `float`
- Other strings → `str`
#### Nested Keys
Use dot notation for nested structures:
```python
config = parse_config_string("database.host:localhost,database.port:5432")
# Result: {"database": {"host": "localhost", "port": 5432}}
```
#### Array Indices
Use numeric keys for array structures:
```python
config = parse_config_string("users.0.name:Alice,users.0.age:30,users.1.name:Bob")
# Result: {"users": [{"name": "Alice", "age": 30}, {"name": "Bob"}]}
```
## API Reference
### `parse_config_string(config_str, *, separator=",", key_value_separator=":", nested_separator=".")`
Parse configuration string into nested dictionary.
**Parameters:**
- `config_str` (str): Configuration string to parse
- `separator` (str, optional): Item separator. Default: `","`
- `key_value_separator` (str, optional): Key-value separator. Default: `":"`
- `nested_separator` (str, optional): Nested key separator. Default: `"."`
**Returns:**
- `dict[str, Any]`: Parsed configuration dictionary
**Examples:**
```python
# Basic usage
parse_config_string("key1:value1,key2:value2")
# {"key1": "value1", "key2": "value2"}
# Nested keys
parse_config_string("cache.enabled:true,db.port:5432")
# {"cache": {"enabled": True}, "db": {"port": 5432}}
# Flags (no value)
parse_config_string("debug,verbose")
# {"debug": None, "verbose": None}
# Custom separators
parse_config_string("a=1;b=2", separator=";", key_value_separator="=")
# {"a": 1, "b": 2}
```
## License
This project is licensed under the MIT License - see the [LICENSE](../../LICENSE) file for details.
## Contributing
This is a personal project by kiarina. While issues and pull requests are welcome, please note that this is primarily developed for personal use.
## Related Packages
- [kiarina-utils-file](../kiarina-utils-file/): File operation utilities
- [kiarina-llm](../kiarina-llm/): LLM-related utilities
Raw data
{
"_id": null,
"home_page": null,
"name": "kiarina-utils-common",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": "kiarina <kiarinadawa@gmail.com>",
"keywords": "common, config, parser, utilities",
"author": null,
"author_email": "kiarina <kiarinadawa@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/14/ed/95540e465893bb2bca9c09954b7ebeefd24067759335f89407d16c7103f4/kiarina_utils_common-1.0.1.tar.gz",
"platform": null,
"description": "# kiarina-utils-common\n\n[](https://badge.fury.io/py/kiarina-utils-common)\n[](https://pypi.org/project/kiarina-utils-common/)\n[](https://opensource.org/licenses/MIT)\n\nCommon utility functions for the kiarina namespace packages.\n\n## Installation\n\n```bash\npip install kiarina-utils-common\n```\n\n## Features\n\n### Configuration String Parser\n\nParse configuration strings into nested dictionaries with automatic type conversion.\n\n```python\nfrom kiarina.utils.common import parse_config_string\n\n# Basic usage\nconfig = parse_config_string(\"cache.enabled:true,db.port:5432\")\n# Result: {\"cache\": {\"enabled\": True}, \"db\": {\"port\": 5432}}\n\n# Flag support (no value)\nconfig = parse_config_string(\"debug,verbose,cache.enabled:true\")\n# Result: {\"debug\": None, \"verbose\": None, \"cache\": {\"enabled\": True}}\n\n# Array indices support\nconfig = parse_config_string(\"items.0:first,items.1:second\")\n# Result: {\"items\": [\"first\", \"second\"]}\n\n# Custom separators\nconfig = parse_config_string(\n \"key1=val1;key2.sub=42\", \n separator=\";\", \n key_value_separator=\"=\"\n)\n# Result: {\"key1\": \"val1\", \"key2\": {\"sub\": 42}}\n```\n\n#### Type Conversion\n\nValues are automatically converted to appropriate types:\n\n- `\"true\"`, `\"True\"` \u2192 `bool(True)`\n- `\"false\"`, `\"False\"` \u2192 `bool(False)`\n- Numeric strings (`\"1\"`, `\"0\"`, `\"-5\"`, `\"3.14\"`) \u2192 `int` or `float`\n- Other strings \u2192 `str`\n\n#### Nested Keys\n\nUse dot notation for nested structures:\n\n```python\nconfig = parse_config_string(\"database.host:localhost,database.port:5432\")\n# Result: {\"database\": {\"host\": \"localhost\", \"port\": 5432}}\n```\n\n#### Array Indices\n\nUse numeric keys for array structures:\n\n```python\nconfig = parse_config_string(\"users.0.name:Alice,users.0.age:30,users.1.name:Bob\")\n# Result: {\"users\": [{\"name\": \"Alice\", \"age\": 30}, {\"name\": \"Bob\"}]}\n```\n\n## API Reference\n\n### `parse_config_string(config_str, *, separator=\",\", key_value_separator=\":\", nested_separator=\".\")`\n\nParse configuration string into nested dictionary.\n\n**Parameters:**\n- `config_str` (str): Configuration string to parse\n- `separator` (str, optional): Item separator. Default: `\",\"`\n- `key_value_separator` (str, optional): Key-value separator. Default: `\":\"`\n- `nested_separator` (str, optional): Nested key separator. Default: `\".\"`\n\n**Returns:**\n- `dict[str, Any]`: Parsed configuration dictionary\n\n**Examples:**\n\n```python\n# Basic usage\nparse_config_string(\"key1:value1,key2:value2\")\n# {\"key1\": \"value1\", \"key2\": \"value2\"}\n\n# Nested keys\nparse_config_string(\"cache.enabled:true,db.port:5432\")\n# {\"cache\": {\"enabled\": True}, \"db\": {\"port\": 5432}}\n\n# Flags (no value)\nparse_config_string(\"debug,verbose\")\n# {\"debug\": None, \"verbose\": None}\n\n# Custom separators\nparse_config_string(\"a=1;b=2\", separator=\";\", key_value_separator=\"=\")\n# {\"a\": 1, \"b\": 2}\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](../../LICENSE) file for details.\n\n## Contributing\n\nThis is a personal project by kiarina. While issues and pull requests are welcome, please note that this is primarily developed for personal use.\n\n## Related Packages\n\n- [kiarina-utils-file](../kiarina-utils-file/): File operation utilities\n- [kiarina-llm](../kiarina-llm/): LLM-related utilities\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Common utility functions for the kiarina namespace packages",
"version": "1.0.1",
"project_urls": {
"Changelog": "https://github.com/kiarina/kiarina-python/blob/main/packages/kiarina-utils-common/CHANGELOG.md",
"Documentation": "https://github.com/kiarina/kiarina-python/tree/main/packages/kiarina-utils-common#readme",
"Homepage": "https://github.com/kiarina/kiarina-python",
"Issues": "https://github.com/kiarina/kiarina-python/issues",
"Repository": "https://github.com/kiarina/kiarina-python"
},
"split_keywords": [
"common",
" config",
" parser",
" utilities"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "6076fc8ad0b55b8c7cfbe268f6047c7e7b50ce60c86935e72186b2678ee9b862",
"md5": "398c2986d0d80ba9dd589acf338bfd5f",
"sha256": "9886861dfbd6759fb80977664541d1a90d6e878fe63f2ec96ffb538a46fa3838"
},
"downloads": -1,
"filename": "kiarina_utils_common-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "398c2986d0d80ba9dd589acf338bfd5f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 5024,
"upload_time": "2025-09-11T08:52:26",
"upload_time_iso_8601": "2025-09-11T08:52:26.414443Z",
"url": "https://files.pythonhosted.org/packages/60/76/fc8ad0b55b8c7cfbe268f6047c7e7b50ce60c86935e72186b2678ee9b862/kiarina_utils_common-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "14ed95540e465893bb2bca9c09954b7ebeefd24067759335f89407d16c7103f4",
"md5": "c8d415e46c223539b16cc2d5f9f7f2f9",
"sha256": "c5cf9b494dbeafd585ff0c7ad84762a3a8001f134ab0e95f24516076a0d13241"
},
"downloads": -1,
"filename": "kiarina_utils_common-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "c8d415e46c223539b16cc2d5f9f7f2f9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 6928,
"upload_time": "2025-09-11T08:52:31",
"upload_time_iso_8601": "2025-09-11T08:52:31.187781Z",
"url": "https://files.pythonhosted.org/packages/14/ed/95540e465893bb2bca9c09954b7ebeefd24067759335f89407d16c7103f4/kiarina_utils_common-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-11 08:52:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kiarina",
"github_project": "kiarina-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "kiarina-utils-common"
}