Skip to main content

Configuration parser with all variables possible to overwrite by environment variables

Project description

Config ENV Parser

This project intents to simplify the process of reading configuration files and exposing these configuration variables to be overwritten with env variables.

Install

pip install config-env-parser

Minimal Example

from iniparser import Config

if __name__ == '__main__':
    c = Config()
    # True indicates recursive scan
    # '.' indicates to start the scanning in '.' as root
    c.scan('.', True)
    # Reads your ini files
    c.read()
    # prints the rendered config file
    print(c.config_rendered)
    # prints the config file with lambda functions in the fields that are exposed to the environment.
    print(c.config)

Generate env markdown file

To enable easy tracking of the created env variables, you can call the Config's to_env method.

from iniparser import Config

if __name__ == '__main__':
    c = Config()
    # True indicates recursive scan
    # '.' starts the scanning in root
    # read reads your ini files
    c.scan('.', True).read()
    # Writes all available env variables to env.md
    c.to_env(output_path='./env.md')

Hinting

You can hint this tool in your ini files by adding a cep: hint. E.g. in your ini file exclude|include|hint

...
; ceb: exclude
excluded_key = excluded_value
; ceb: include
included_key = included_value
; ceb: hint
depends_key = depends_value

The depends_key depends on the settings of the Config class. If your setting of the mode was all_allowed, the hint keyword will exclude the depends_key. If your mode setting is all_forbidden on the other hand, the depends_key will be included. In short: The hint keyword will do the opposite of the mode for the following line. If you place the ceb: command before a section, it will apply this to the whole section.

The include will provide a always exposed ENV var coming from the name. The exclude will never expose the config variable to the ENV.

Exposed in this context

Exposed in this context means, that an automated ENV variable is created and if the ENV variable is set or changed, the config variable is overwritten by the ENV variable.

Find an example

In example you can find an example config.ini and the usage of the config parser in example/example.py.

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

config-env-parser-0.0.3.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

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

config_env_parser-0.0.3-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file config-env-parser-0.0.3.tar.gz.

File metadata

  • Download URL: config-env-parser-0.0.3.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for config-env-parser-0.0.3.tar.gz
Algorithm Hash digest
SHA256 9077b7904f3661f908a4769319061702837fc6973b553778842895e073cdfcf7
MD5 51ab91dbd2c670cf26f6e765d047d60c
BLAKE2b-256 b1b0862fbbd7280b918468ca2eaf6931b8f3b73760ce8e923af93fa4dafb7f15

See more details on using hashes here.

File details

Details for the file config_env_parser-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: config_env_parser-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for config_env_parser-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a14fda25a560609c5da6889db4619d38ced020a2c6d39ee5fb2d24c77dd2ee3e
MD5 8b814bd06f7ceec0b7552eddb26b61fc
BLAKE2b-256 33342fed08d12fb67a3e1be81a048196a9d8767b5be018d771a37f141ed28d63

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