Skip to main content

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.

Release files for config-env-parser 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for config-env-parser 0.0.3
File Size Uploaded
config-env-parser-0.0.3.tar.gz 16.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for config-env-parser 0.0.3
File Interpreter ABI Platform
config_env_parser-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 26.8 kB

Release files / config-env-parser-0.0.3.tar.gz

Download URL config-env-parser-0.0.3.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9077b7904f3661f908a4769319061702837fc6973b553778842895e073cdfcf7
BLAKE2b-256 checksum
How to use checksums
b1b0862fbbd7280b918468ca2eaf6931b8f3b73760ce8e923af93fa4dafb7f15
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / config_env_parser-0.0.3-py3-none-any.whl

Download URL config_env_parser-0.0.3-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a14fda25a560609c5da6889db4619d38ced020a2c6d39ee5fb2d24c77dd2ee3e
BLAKE2b-256 checksum
How to use checksums
33342fed08d12fb67a3e1be81a048196a9d8767b5be018d771a37f141ed28d63
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page