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
configobjIt supports content verification and default values thanks to
validate.Validator.Example
>>> Cfg = Config('config.ini', interpolation='template') >>> Cfg.opt_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.Validatorto 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
ConfigObjinstance loaded from a filepatch(cfg, cfgpatch[, validate])Replace config values of
cfgby those ofcfgpatchreset([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