| Home | Trees | Indices | Help |
|
|---|
|
|
A wrapper around ConfigParser that defines syntax and types within the configuration options.
This tries to do for configuration processing what optparse did for command line option processing: A declarative way of handling the main chores.
The idea is that, in a client program, you say something like:
from pftf.fancyconfig import (Configuration, Section, ConfigError,
...(items you want)...)
_config = Config(
Section(...
XYConfigItem(...)
),
Section(...
...
)
)
get = _config.get
set = _config.set
if __name__=="__main__":
print fancyconfig.makeTxtDocs(_config)
else:
try:
fancyconfig.readConfiguration(_config, None,
os.path.join(dataDir, "config"))
except ConfigError, msg:
import sys
sys.stderr.write("%s: %s\n"%(
sys.argv[0], unicode(msg).encode("utf-8")))
sys.exit(0)
and be done with most of it.
For examples of how this is used, see pftf (http://www.tfiu.de/pftf) or pysmap (link coming up).
| Classes | |
|
ConfigError is the base class of the user visible exceptions from this module. |
|
|
ParseError is raised by ConfigItem's parse methods if there is a problem with the input. |
|
|
NoConfigItem is raised by Configuration if a non-existing configuration item is set or requested. |
|
|
BadConfigValue is raised by getConfiguration when there is a syntax error or the like in a value. |
|
|
SyntaxError is raised when the input file syntax is bad (i.e., on configparser.ParsingErrors) |
|
|
ConfigItem A description of a configuration item including methods to parse and unparse them. |
|
|
StringConfigItem A config item containing unicode strings. |
|
|
BytestringConfigItem A config item containing byte strings. |
|
|
IntConfigItem A config item containing an integer. |
|
|
FloatConfigItem A config item containing a float. |
|
|
ListConfigItem A ConfigItem containing a list of strings, comma separated. |
|
|
SetConfigItem A set-valued ListConfigItem for quick existence lookups. |
|
|
IntListConfigItem A ConfigItem containing a comma separated list of ints. |
|
|
IntSetConfigItem A set-valued IntListConfigItem for fast existence lookups. |
|
|
DictConfigItem A config item that contains a concise representation of a string-string mapping. |
|
|
BooleanConfigItem A config item that contains a boolean and can be parsed from many fancy representations. |
|
|
EnumeratedConfigItem A ConfigItem taking string values out of a set of possible strings. |
|
|
PathConfigItem A ConfigItem for a unix shell-type path. |
|
|
PathRelativeConfigItem A configuration item interpreted relative to a path given in the general section. |
|
|
ExpandedPathConfigItem A configuration item in that returns its value expandusered. |
|
|
Section A section within the configuration. |
|
|
DefaultSection is the default section, named by defaultSection above. |
|
|
MagicSection A section that creates new keys on the fly. |
|
|
Configuration A collection of config Sections and provides an interface to access them and their items. |
|
| Functions | |||
|
|||
|
|||
| Variables | |
defaultSection =
|
|
BAD_CONFIG_ITEM_JUST_WARNS = True
|
|
__package__ =
|
|
| Function Details |
fills the Configuration config with values from the the two locations. File names that are none or point to non-existing locations are ignored. |
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Thu May 2 07:29:09 2019 | http://epydoc.sourceforge.net |