Skip to main content

Another Python configuration tool

Project description

Cool Config

Simple way to use configuration files with Python configuration model.

Requires

Python 3.6+

Usage

Simple usage example:

from cool_config import *


class Config(AbstractConfig):
    """
    Configuration model inherits from AbstractConfig, and all configuration sections from Section
    """
    class main(Section):
        a = Integer

    b = Integer


config = Config()  # create global configuration object and import it


# more examples available in test/main.py
if __name__ == '__main__':
    config_data = {
        'main': {
            'a': 5
        },
        'b': 42
    }

    # config.load('config.yml')  # initialize configuration with config.yml in 
    #   you application entry point (before `config` usage)
    config.update_from_dict(config_data)


    print(config)  # {'b': 42, 'main': {'a': 5}}
    print(config.main.a)  # 5
    print(config.b)  # 42

    config_data_b = {
        'main': {
            'a': 55
        },
    }
    config.update_from_dict(config_data_b)
    print(config)  # {'b': 42, 'main': {'a': 55}}

    """
    ENVIRONMENT:
        TEST__main__a = '6'
        TEST__b = '22'
        THE_ANSWER_KEY = '42'
    """
    config.update_from_env('TEST', delimiter='__')
    print(config)  # {'b': 22, 'main': {'a': 6}}

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

cool_config-0.2.3.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cool_config-0.2.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file cool_config-0.2.3.tar.gz.

File metadata

  • Download URL: cool_config-0.2.3.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for cool_config-0.2.3.tar.gz
Algorithm Hash digest
SHA256 dc9373abc586e8c84bd64ac0171026a142195d65d4edf15dd3be411d25a8b5c3
MD5 d19857c376a48b2fbc3736ede6bb2fa3
BLAKE2b-256 5a99c6ab6bb51c3291e1883f7900d2302b16a8c6914912c82011b7704d6d7dfc

See more details on using hashes here.

File details

Details for the file cool_config-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: cool_config-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for cool_config-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 973dcc8b70558cc428db62a2eba763d5525e93b09a63482121fede57b0f8a9b2
MD5 eea1db1c1e5f477f0dfd05a448285d81
BLAKE2b-256 a335275207ef7d082afefaf9c287256a0fdc68f4c6788b94cc1f0065e1b0e525

See more details on using hashes here.

Supported by

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