A package for flexible configuration of all your projects. Supports JSON and YAML config files.
pip install py-configger
The main tools provided by the package are the BasicConfig and SingleConfig classes.
Standard config implementation. Its peculiarity is the ability to be defined only in one place, and then be passed to factories as an argument or imported by other modules.
from configger import BasicConfig
basic_config = BasicConfig("config.yml")
print(basic_config['version'])
print(basic_config('version').value)
Config type implementing the Singleton pattern. You can get the same version of your config anywhere in your project.
main.py
from configger import SingleConfig
from second import do_stuff
single_config = SingleConfig("config.json")
single_config['color'] = 'orange'
do_stuff()
second.py
from configger.config import SingleConfig
def do_stuff():
config = SingleConfig(show_config=True)
- Expand functionality to access other types of config files
- Add the ability to create nested fields
- Retrieving a config file by URL