# Easy config
Simple class to manage configurations.
## Installation
Classic through pip or your favourite package manager:
```shell
pip install ez-config-mgt
```
## Usage
You want to define a default configuration and allow users to override some of the settings.
The class simply get the config value for the user's specific config and get the default value if not defined.
First thing is to instantiate a configuration.
```python
from ez_config_mgt import BaseConfig
config = BaseConfig('test')
print(config)
```
'test' is the name of the configuration. You can define several configurations.
You can tailor the default configuration to your needs.
```python
from ez_config_mgt import BaseConfig, extend_default_config
extend_default_config({'mydefaults': { 'example': 'test' }})
config = BaseConfig('test')
print(config)
```
Class is meant to be inherited. It's quite useful if you just need one config and prefer not to bother passing arguments in your main code.
```python
from ez_config_mgt import BaseConfig
class MyToolConfig(BaseConfig):
def __init__(self):
super().__init__('mytool', default_conf = {
'config': { 'file': 'config', 'directory': './conf' },
'mydefaults': { 'example': 'test' }})
config = MyToolConfig()
print(config)
```
Alternatively, you can first extend the default config. It's rather convenient if your package is made of multiple parts, each of them having its own configuration needs that you want to deal with in one single config.
```python
from ez_config_mgt import BaseConfig, extend_default_config
extend_default_config({'mydefaults': { 'example': 'test' }})
class MyToolConfig(BaseConfig):
def __init__(self):
super().__init__('mytool')
config = MyToolConfig()
print(config)
```
## Acknowledgements
This is quite simple stuff that was written to speed up config management for internal needs. It's published to be criticized, of course, but mainly to make reuse and deployment easier.
Raw data
{
"_id": null,
"home_page": null,
"name": "ez_config_mgt",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.13,>=3.11",
"maintainer_email": null,
"keywords": "config, management",
"author": "Christophe Druet",
"author_email": "christophe.druet@entsoe.eu",
"download_url": "https://files.pythonhosted.org/packages/46/71/21287d93aebd674fcf890e0174e11c23772e2d06e7209a711a72210ae072/ez_config_mgt-0.1.1.tar.gz",
"platform": null,
"description": "# Easy config\n\nSimple class to manage configurations.\n\n## Installation\n\nClassic through pip or your favourite package manager:\n\n```shell\npip install ez-config-mgt\n```\n\n## Usage\n\nYou want to define a default configuration and allow users to override some of the settings. \nThe class simply get the config value for the user's specific config and get the default value if not defined.\n\nFirst thing is to instantiate a configuration. \n\n```python\nfrom ez_config_mgt import BaseConfig\n\nconfig = BaseConfig('test')\n\nprint(config)\n```\n\n'test' is the name of the configuration. You can define several configurations.\n\nYou can tailor the default configuration to your needs.\n\n```python\nfrom ez_config_mgt import BaseConfig, extend_default_config\n\nextend_default_config({'mydefaults': { 'example': 'test' }})\n\nconfig = BaseConfig('test')\n\nprint(config)\n```\n\nClass is meant to be inherited. It's quite useful if you just need one config and prefer not to bother passing arguments in your main code.\n\n```python\nfrom ez_config_mgt import BaseConfig\n\nclass MyToolConfig(BaseConfig):\n def __init__(self):\n super().__init__('mytool', default_conf = { \n 'config': { 'file': 'config', 'directory': './conf' }, \n 'mydefaults': { 'example': 'test' }})\n\nconfig = MyToolConfig()\n\nprint(config)\n```\n\nAlternatively, you can first extend the default config. It's rather convenient if your package is made of multiple parts, each of them having its own configuration needs that you want to deal with in one single config.\n\n```python\nfrom ez_config_mgt import BaseConfig, extend_default_config\n\nextend_default_config({'mydefaults': { 'example': 'test' }})\n\nclass MyToolConfig(BaseConfig):\n def __init__(self):\n super().__init__('mytool')\n\nconfig = MyToolConfig()\n\nprint(config)\n```\n\n## Acknowledgements\n\nThis is quite simple stuff that was written to speed up config management for internal needs. It's published to be criticized, of course, but mainly to make reuse and deployment easier.",
"bugtrack_url": null,
"license": "MIT",
"summary": "Easy config management",
"version": "0.1.1",
"project_urls": null,
"split_keywords": [
"config",
" management"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "dd4ab88b23fa11fb964cba8a80eb500bbbaf1086efa9bde92e59f1b5f6eb6c8e",
"md5": "6563b80b64818bc4139d8ba71c857097",
"sha256": "8c3fe771ad671553f5bdd802d39894c3ecb160fd6bc025778a7c0cab132067ab"
},
"downloads": -1,
"filename": "ez_config_mgt-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6563b80b64818bc4139d8ba71c857097",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.13,>=3.11",
"size": 5603,
"upload_time": "2024-08-13T15:59:56",
"upload_time_iso_8601": "2024-08-13T15:59:56.594413Z",
"url": "https://files.pythonhosted.org/packages/dd/4a/b88b23fa11fb964cba8a80eb500bbbaf1086efa9bde92e59f1b5f6eb6c8e/ez_config_mgt-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "467121287d93aebd674fcf890e0174e11c23772e2d06e7209a711a72210ae072",
"md5": "5f91c3622ce3fa1d7de932b87b25bd97",
"sha256": "9c7c48fe45fc9398cfbf9177027bef8253ee157335ccd9c2bd592a7b1723d5d7"
},
"downloads": -1,
"filename": "ez_config_mgt-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "5f91c3622ce3fa1d7de932b87b25bd97",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.13,>=3.11",
"size": 5353,
"upload_time": "2024-08-13T15:59:58",
"upload_time_iso_8601": "2024-08-13T15:59:58.625097Z",
"url": "https://files.pythonhosted.org/packages/46/71/21287d93aebd674fcf890e0174e11c23772e2d06e7209a711a72210ae072/ez_config_mgt-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-13 15:59:58",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "ez_config_mgt"
}