Quick-start
import io
file = io.StringIO("""
foo = 1
""")
import os
os.environ["GRAOU_BAZ"] = "OUAF"
u = Ulticonf(configuration_file=file, environment_prefix="GRAOU_")
u.add_argument("--foo", type=int)
u.add_argument("--bar", type=int)
u.add_argument("--baz", type=str)
out = u.parse_args(["--bar", "2"])
assert out.foo == 1
assert out.bar == 2
assert out.baz == "OUAF"
API reference
For add_argument
, see argparse
s documentation of the same method.
What
Simplify parameterization of scripts
How
By providing a single interface for handling various sources of parameterization
How but in details
Configuration sources
Using the same interface as argparse
, ulticonf
also checks value defined in:
ulticonf
checks value defined in:
- command line
- environment variable
- configuration file
- default value (NOT IMPLEMENTED YET)
Configuration file
For now, only a flat TOML file is supported. Oops :)
TODOs
- support various filetypes
- implement extra
argparse
functions (e.g.subgroup
) - support non-flat config
- tests...
- doc.......