Welcome to cfglib’s documentation!¶
Contents¶
Example¶
class PointConfig(cfglib.SpecValidatedConfig):
x = cfglib.IntSetting()
y = cfglib.IntSetting()
class ExampleToolConfig(cfglib.SpecValidatedConfig):
message = cfglib.StringSetting(default='Hello!')
config_file = cfglib.StringSetting(default=None)
points = cfglib.ListSetting(
subsetting=cfglib.DictSetting(subtype=PointConfig),
)
cfg = ExampleToolConfig([
{'points': [{'x': 1, 'y': 2}]},
EnvConfig(prefix='EXAMPLE_', lowercase=True),
])
print(cfg.message)
# when run with EXAMPLE_MESSAGE=hello will print hello
print(cfg.points)
# will print [<PointConfig {'x': 1, 'y': 2}>]
Description¶
cfglib¶
An extensible configuration library
- Free software: MIT license
- Documentation: https://cfglib.readthedocs.io.
Features¶
- Describe config schema and perform validation
- Numerous utils to compose configs from multiple sources, etc.
- Read settings from environment