A simple configuration files manager package
Project description
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 : {param1} -> Value 1
- the use of environment variables for sensitive data like passwords is also possible : through this text {os_environ[password]}
{
"__name": "MainConfig",
"__parent": "demo.ParentConfig",
"param2": "Value 2 and {param1}",
"user_info": {"user": "username", "password": "{os_environ[password]}"}
}
To import those configuration using configDmanager, use this demo code :
from configDmanager import import_config
class RandomClass:
def __init__(self, param1, param2, user_info):
print(f"param1: {param1}")
print(f"param2: {param2}")
print(f'my user: {user_info.user}')
print(f'my user: {user_info.password}')
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', **config[['param1', 'user_info']])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ConfigDmanager-0.0.2.tar.gz
(4.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ConfigDmanager-0.0.2.tar.gz.
File metadata
- Download URL: ConfigDmanager-0.0.2.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81703f42ca6435ec1d78879141bf994a6721d32d457d0ab6d8cb375fb1e30c83
|
|
| MD5 |
6527cc0933c13581f22b43b5356fd159
|
|
| BLAKE2b-256 |
6d891b08e069fb63b9256bf399475ac4615d6144b585b4466838b511d321b9cd
|
File details
Details for the file ConfigDmanager-0.0.2-py3-none-any.whl.
File metadata
- Download URL: ConfigDmanager-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1f75b1bc63725d6ff8f07f8fc2f52e54a8d81271ef93aae3894f0c638fbf85c
|
|
| MD5 |
27b17d4dd8e6bfd19c896b69f8520edc
|
|
| BLAKE2b-256 |
44f0f35dc296e81a7654be51c263b32dc095206d5a3b30c4b30fcaa17fc91eaf
|