import pydataconfig
import dataclasses
@dataclasses.dataclass
class Config:
str_field: str = None
config = Config()
config_loader = pydataconfig.create_config_loader(
config,
cli=True,
dot_env=True,
env=True,
system_global=True,
system_user=True,
domain='com.company.product',
company_name='Company',
product_name='Product')
config_loader.load()
Load app external configuration into a dataclass
easily.
Config will be populated according to the following precedence:
- System config
- Windows:
/HKEY_LOCAL_MACHINE/SOFTWARE/Company/Product/str_field
- Windows:
- User config
- Windows:
/HKEY_CURRENT_USER/Software/Company/Product/str_field
- Mac:
defaults read com.company.product str_field
- Windows:
- dot-env:
.env
:STR_FIELD=VALUE
- Environment variables:
STR_FIELD=VALUE
- CLI:
--str-field value