/polidoro-config

Polidoro Config it is a configuration manager for you project

Primary LanguagePythonMIT LicenseMIT

Polidoro Config

Polidoro Config it is a configuration manager for you project

Code Quality CodeQL Upload Python Package Documentation Status
Latest Version GitHub Release Date
GitHub commits since latest release (by SemVer including pre-releases) GitHub last commit
GitHub issues GitHub pull requests

Coverage Quality Gate Status Security Rating Maintainability Rating Reliability Rating
Code Smells Duplicated Lines (%) Vulnerabilities Bugs Technical Debt
DeepSource
PyPI

Python Versions
GitHub branch check runs
GitHub branch check runs
GitHub branch check runs

Basic Usage

Create a class inheriting from ConfigBase

from pconfig import ConfigBase

class Config(ConfigBase):
	DB_HOST = 'localhost'
	ENVIRONMENT = 'development'
	...

When the class is instantiated will load from environment variables.

# script.py
from pconfig import ConfigBase

class Config(ConfigBase):
	MY_VAR = 'default_value'

print(Config.MY_VAR)
>>> python script.py
default_value

>>> MY_VAR="new_value" python script.py
new_value

If you have the python-dotenv installed will load the .env automatically. Also, you can load from a .yaml file setting the file path in the Config class:

# script.py
from pconfig import ConfigBase

class Config(ConfigBase):
	file_path = "my_config.yml"
	MY_VAR = 'default_value'

For more information see the Documentation