ConfigDmanager
Installation
A simple pip install will do :
python -m pip install ConfigDmanager
Use
-
Suppose we have two Configuration files ( of json type ) :
-
ParentConfig.json :
{ "__name": "ParentConfig", "param1": "Value 1" }
-
MainConfig.json :
- The __parent parameter specifies the path to another configuration file that will give us default values ( Think of it as inheritance ).
- The text contained between brackets will be reinterpreted in runtime :
in the example below ${param1} will be reinterpreted as "Value 1"
- The use of environment variables for sensitive data like passwords is also possible : through this text ${os_environ[password]}
- You can also read the content of a text file with a simple : ${read_file[file_path]} as shown in the example below.
{ "__name": "MainConfig", "__parent": "demo.ParentConfig", "param2": "Value 2 and ${param1}", "user_info": {"user": "username", "password": "${os_environ[password]}"}, "long_text": "${read_file[./demo.py]}" }
-
-
To import those configuration using configDmanager, use this demo code :
from configDmanager import import_config
class RandomClass:
def __init__(self, param1, param2, user_info, long_text):
print(f"param1: {param1}")
print(f"param2: {param2}")
print(f'my user: {user_info.user}')
print(f'my user: {user_info.password}')
print(f'my long text: "{long_text[:40]}"')
config = import_config('MainConfig')
print("## Object 1")
obj = RandomClass(**config)
# You can also select specific keys
print("## Object 2")
another_obj = RandomClass(param2='Another Value', long_text="Not so long", **config[['param1', 'user_info']])
Export Config file
You can export a Config by simply using the export_config function
from configDmanager import export_config, Config
config = Config({'my_param': 'my_value'})
export_config(config, 'NewConfig')
If you wish to modify an existing config, you can use update_config function :
from configDmanager import update_config
# You can use a dict to update Config values
update_config({'param' : 'value'}, 'MyConfig')
# You can also use a callable that takes the config returns a dict
update_config(lambda conf: {'numeric': conf['numeric'] + 1}, 'MyConfig')
Metadata
Release files for ConfigDmanager 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ConfigDmanager-0.2.0.tar.gz | 6.4 kB | Without provenance | Details for ConfigDmanager-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ConfigDmanager-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for ConfigDmanager-0.2.0-py3-none-any.whl |
Total release size: 15.2 kB
Release files / ConfigDmanager-0.2.0.tar.gz
| Download URL | ConfigDmanager-0.2.0.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
310fa89da0b18e551e91d9585e2bd82aa80f4bf8638fcbc39e2eaa54fcafcfed
|
|
BLAKE2b-256 checksum How to use checksums |
8fe50d2c7de8b1c4df84dd4fc4e60146dd251ac6378f0859852c92775b7d170f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
|
Release files / ConfigDmanager-0.2.0-py3-none-any.whl
| Download URL | ConfigDmanager-0.2.0-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
310e44d75e7c13184ea3f3dbe825ad83ac991f311c2e72f8ee77a561d7bdbebc
|
|
BLAKE2b-256 checksum How to use checksums |
bcb8b3179b90461602780004d82f01ae5bb34b48e6d763270b9dee705bd06bfe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
|
Security for ConfigDmanager 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.