Copyright (C) 2000-2012 |
GNU Info (python2.1-lib.info)ConfigParserConfiguration file parser ========================= Configuration file parser. This module was written by Ken Manheimer <klm@digicool.com>. This module was written by Barry Warsaw <bwarsaw@python.org>. This module was written by Eric S. Raymond <esr@thyrsus.com>. This manual section was written by Christopher G. Petrilli <petrilli@amber.org>. This module defines the class `ConfigParser'. The `ConfigParser' class implements a basic configuration file parser language which provides a structure similar to what you would find on Microsoft Windows INI files. You can use this to write Python programs which can be customized by end users easily. The configuration file consists of sections, lead by a `[section]' header and followed by `name: value' entries, with continuations in the style of RFC 822 ; `name=value' is also accepted. Note that leading whitespace is removed from values. The optional values can contain format strings which refer to other values in the same section, or values in a special `DEFAULT' section. Additional defaults can be provided upon initialization and retrieval. Lines beginning with `#' or `;' are ignored and may be used to provide comments. For example: foodir: %(dir)s/whatever dir=frob would resolve the `%(dir)s' to the value of `dir' (`frob' in this case). All reference expansions are done on demand. Default values can be specified by passing them into the `ConfigParser' constructor as a dictionary. Additional defaults may be passed into the `get()' method which will override all others. `ConfigParser([defaults])' Return a new instance of the `ConfigParser' class. When DEFAULTS is given, it is initialized into the dictionary of intrinsic defaults. The keys must be strings, and the values must be appropriate for the `%()s' string interpolation. Note that __NAME__ is an intrinsic default; its value is the section name, and will override any value provided in DEFAULTS. `NoSectionError' Exception raised when a specified section is not found. `DuplicateSectionError' Exception raised when multiple sections with the same name are found, or if `add_section()' is called with the name of a section that is already present. `NoOptionError' Exception raised when a specified option is not found in the specified section. `InterpolationError' Exception raised when problems occur performing string interpolation. `InterpolationDepthError' Exception raised when string interpolation cannot be completed because the number of iterations exceeds `MAX_INTERPOLATION_DEPTH'. `MissingSectionHeaderError' Exception raised when attempting to parse a file which has no section headers. `ParsingError' Exception raised when errors occur attempting to parse a file. `MAX_INTERPOLATION_DEPTH' The maximum depth for recursive interpolation for `get()' when the RAW parameter is false. Setting this does not change the allowed recursion depth. See also: Note: shlex Support for a creating UNIX shell-like minilanguages which can be used as an alternate format for application configuration files. automatically generated by info2www version 1.2.2.9 |