microprobe.utils.config.DuplicateConfigParser¶
-
class
DuplicateConfigParser
(defaults=None, dict_type=<class 'collections.OrderedDict'>, allow_no_value=False)[source]¶ Bases:
ConfigParser.ConfigParser
,object
A helper class to allow multiple configuration files.
This class extends the base class behavior by allowing to read multiple config files instead of a single one. Configuration options are appended or reset depending on the configuration option type. Scalar values are reset, i.e. last configuration file setting the value is used. List values are appended.
-
__init__
(defaults=None, dict_type=<class 'collections.OrderedDict'>, allow_no_value=False)¶ x.__init__(…) initializes x; see help(type(x)) for signature
Methods
get
(section, option[, raw])Get an option value for a given section. items
(section[, raw])Return a list of tuples with (name, value) for each option in the section. read
(filenames[, overwrite_first])Read and parse a filename or a list of filenames. readfp
(fp[, filename, overwrite_first])Like read() but the argument must be a file-like object. write
(fp[, write_empty])Write an .ini-format representation of the configuration state. Attributes
OPTCRE
OPTCRE_NV
SECTCRE
-
read
(filenames, overwrite_first=False)[source]¶ Read and parse a filename or a list of filenames.
Files that cannot be opened are silently ignored; this is designed so that you can specify a list of potential configuration file locations (e.g. current directory, user’s home directory, system wide directory), and all existing configuration files in the list will be read. A single filename may also be given.
Return list of successfully read files.
-
get
(section, option, raw=False)[source]¶ Get an option value for a given section.
If vars is provided, it must be a dictionary. The option is looked up in vars (if provided), section, and in defaults in that order.
All % interpolations are expanded in the return values, unless the optional argument raw is true. Values for interpolation keys are looked up in the same manner as the option.
The section DEFAULT is special.
-
items
(section, raw=False)[source]¶ Return a list of tuples with (name, value) for each option in the section.
All % interpolations are expanded in the return values, based on the defaults passed into the constructor, unless the optional argument raw is true. Additional substitutions may be provided using the vars argument, which must be a dictionary whose contents overrides any pre-existing defaults.
The section DEFAULT is special.
-
readfp
(fp, filename=None, overwrite_first=False)[source]¶ Like read() but the argument must be a file-like object.
The fp argument must have a readline method. Optional second argument is the filename, which if not given, is taken from fp.name. If fp has no name’ attribute, `<???> is used.
-
write
(fp, write_empty=False)[source]¶ Write an .ini-format representation of the configuration state.
-
OPTCRE
= <_sre.SRE_Pattern object>¶
-
OPTCRE_NV
= <_sre.SRE_Pattern object>¶
-
SECTCRE
= <_sre.SRE_Pattern object>¶
-
add_section
(section)¶ Create a new section in the configuration.
Raise DuplicateSectionError if a section by the specified name already exists. Raise ValueError if name is DEFAULT or any of it’s case-insensitive variants.
-
defaults
()¶
-
getboolean
(section, option)¶
-
getfloat
(section, option)¶
-
getint
(section, option)¶
-
has_option
(section, option)¶ Check for the existence of a given option in a given section.
-
has_section
(section)¶ Indicate whether the named section is present in the configuration.
The DEFAULT section is not acknowledged.
-
options
(section)¶ Return a list of option names for the given section name.
-
optionxform
(optionstr)¶
-
remove_option
(section, option)¶ Remove an option.
-
remove_section
(section)¶ Remove a file section.
-
sections
()¶ Return a list of section names, excluding [DEFAULT]
-
set
(section, option, value=None)¶ Set an option.
-