Skip to main content

Easy config management

Project description

Easy config

Simple class to manage configurations.

Installation

Classic through pip or your favourite package manager:

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.

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.

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.

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.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ez_config_mgt-0.1.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

ez_config_mgt-0.1.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file ez_config_mgt-0.1.1.tar.gz.

File metadata

  • Download URL: ez_config_mgt-0.1.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.6 Darwin/23.5.0

File hashes

Hashes for ez_config_mgt-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9c7c48fe45fc9398cfbf9177027bef8253ee157335ccd9c2bd592a7b1723d5d7
MD5 5f91c3622ce3fa1d7de932b87b25bd97
BLAKE2b-256 467121287d93aebd674fcf890e0174e11c23772e2d06e7209a711a72210ae072

See more details on using hashes here.

File details

Details for the file ez_config_mgt-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ez_config_mgt-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.6 Darwin/23.5.0

File hashes

Hashes for ez_config_mgt-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8c3fe771ad671553f5bdd802d39894c3ecb160fd6bc025778a7c0cab132067ab
MD5 6563b80b64818bc4139d8ba71c857097
BLAKE2b-256 dd4ab88b23fa11fb964cba8a80eb500bbbaf1086efa9bde92e59f1b5f6eb6c8e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page