xoa.cfgm.ConfigManager
- class xoa.cfgm.ConfigManager(cfgspecfile=None, validator=None, interpolation='template', encoding=None, boolean_false=True, splitsecdesc=False, cfgfilter=None, cfgfilter_default=False, warn_empty_specs=False)[source]
A configuration management class based on
configobj
It supports content verification and default values thanks to
validate.Validator
.Example
>>> Cfg = Config('config.ini', interpolation='template') >>> Cfg.arg_parse() >>> cfg = Cfg.load('config.cfg')
See also
configobj.ConfigObj
,validate.Validator
- __init__(cfgspecfile=None, validator=None, interpolation='template', encoding=None, boolean_false=True, splitsecdesc=False, cfgfilter=None, cfgfilter_default=False, warn_empty_specs=False)[source]
- Parameters:
cfgspecfile (optional) – The specification file to be used with this.
validator (
validate.Validator
) – A customvalidate.Validator
to use or a mapping dict of validator functions.interpolation (optional) – See
configobj.ConfigObj
.boolean_false (optional) – Make sure that booleans have a default value.
splitsecdesc (optional) – Section descriptions are split in two components separated by ‘:’.
Methods
arg_long_help
([rst, usage, description])Get the generic long help from config specs
arg_parse
([parser, exc, parse, args, ...])Commandline options (
argparse
) and config mixer.arg_patch
(parser[, exc, cfgfileopt])Call to
arg_parse()
andpatch()
get_defaults
([nocomments, interpolation])Get the default config
get_rst
([mode])Convert the default config to rst with
cfg2rst()
get_spec
(sec, key, **kwargs)See
get_spec()
load
([cfgfile, patch, validate, force, ...])Get a
ConfigObj
instance loaded from a filepatch
(cfg, cfgpatch[, validate])Replace config values of
cfg
by those ofcfgpatch
reset
([cfgfile, backup, nocomments, verbose])Reset a config file to default values
to_rst
([mode])Convert the default config to rst with
cfg2rst()
Attributes
Default config