diff options
author | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-05-14 22:44:22 (GMT) |
---|---|---|
committer | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-05-14 22:44:22 (GMT) |
commit | e2514c6f1089ab1cdfba6ddc1dbaed1d37dd2be8 (patch) | |
tree | 1f0356149ed33a4bcca694f4f16b6f55c42126a6 /Doc/library | |
parent | 0a11f96f673dc6f3a7d43d58c249e1d183b1891c (diff) | |
download | cpython-e2514c6f1089ab1cdfba6ddc1dbaed1d37dd2be8.zip cpython-e2514c6f1089ab1cdfba6ddc1dbaed1d37dd2be8.tar.gz cpython-e2514c6f1089ab1cdfba6ddc1dbaed1d37dd2be8.tar.bz2 |
Updated import statements to use the new `configparser` module name.
Updated the documentation to use the new name.
Revert addition of the stub entry for the old name.
Georg, I am reverting your changes since this commit should propagate
to py3k.
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/configparser.rst | 33 | ||||
-rw-r--r-- | Doc/library/logging.rst | 26 |
2 files changed, 27 insertions, 32 deletions
diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst index 50373fc..fe811de 100644 --- a/Doc/library/configparser.rst +++ b/Doc/library/configparser.rst @@ -1,21 +1,14 @@ -:mod:`ConfigParser` --- Configuration file parser +:mod:`configparser` --- Configuration file parser ================================================= -.. module:: ConfigParser - :synopsis: Old name for the configparser module. - .. module:: configparser :synopsis: Configuration file parser. + .. moduleauthor:: Ken Manheimer <klm@zope.com> .. moduleauthor:: Barry Warsaw <bwarsaw@python.org> .. moduleauthor:: Eric S. Raymond <esr@thyrsus.com> .. sectionauthor:: Christopher G. Petrilli <petrilli@amber.org> -.. note:: - The :mod:`ConfigParser` module has been renamed to :mod:`configparser` in - Python 3.0. It is importable under both names in Python 2.6 and the rest of - the 2.x series. - .. index:: pair: .ini; file pair: configuration; file @@ -232,9 +225,9 @@ RawConfigParser Objects load the required file or files using :meth:`readfp` before calling :meth:`read` for any optional files:: - import ConfigParser, os + import configparser, os - config = ConfigParser.ConfigParser() + config = configparser.ConfigParser() config.readfp(open('defaults.cfg')) config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')]) @@ -374,9 +367,9 @@ Examples An example of writing to a configuration file:: - import ConfigParser + import configparser - config = ConfigParser.RawConfigParser() + config = configparser.RawConfigParser() # When adding sections or items, add them in the reverse order of # how you want them to be displayed in the actual file. @@ -399,9 +392,9 @@ An example of writing to a configuration file:: An example of reading the configuration file again:: - import ConfigParser + import configparser - config = ConfigParser.RawConfigParser() + config = configparser.RawConfigParser() config.read('example.cfg') # getfloat() raises an exception if the value is not a float @@ -418,9 +411,9 @@ An example of reading the configuration file again:: To get interpolation, you will need to use a :class:`ConfigParser` or :class:`SafeConfigParser`:: - import ConfigParser + import configparser - config = ConfigParser.ConfigParser() + config = configparser.ConfigParser() config.read('example.cfg') # Set the third, optional argument of get to 1 if you wish to use raw mode. @@ -435,10 +428,10 @@ To get interpolation, you will need to use a :class:`ConfigParser` or Defaults are available in all three types of ConfigParsers. They are used in interpolation if an option used is not defined elsewhere. :: - import ConfigParser + import configparser # New instance with 'bar' and 'baz' defaulting to 'Life' and 'hard' each - config = ConfigParser.SafeConfigParser({'bar': 'Life', 'baz': 'hard'}) + config = configparser.SafeConfigParser({'bar': 'Life', 'baz': 'hard'}) config.read('example.cfg') print config.get('Section1', 'foo') # -> "Python is fun!" @@ -451,7 +444,7 @@ The function ``opt_move`` below can be used to move options between sections:: def opt_move(config, section1, section2, option): try: config.set(section2, option, config.get(section1, option, 1)) - except ConfigParser.NoSectionError: + except configparser.NoSectionError: # Create non-existent section config.add_section(section2) opt_move(config, section1, section2, option) diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst index b2686aa..6ece996 100644 --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -2275,18 +2275,20 @@ in :mod:`logging` itself) and defining handlers which are declared either in Configuration file format ^^^^^^^^^^^^^^^^^^^^^^^^^ -The configuration file format understood by :func:`fileConfig` is based on -ConfigParser functionality. The file must contain sections called ``[loggers]``, -``[handlers]`` and ``[formatters]`` which identify by name the entities of each -type which are defined in the file. For each such entity, there is a separate -section which identified how that entity is configured. Thus, for a logger named -``log01`` in the ``[loggers]`` section, the relevant configuration details are -held in a section ``[logger_log01]``. Similarly, a handler called ``hand01`` in -the ``[handlers]`` section will have its configuration held in a section called -``[handler_hand01]``, while a formatter called ``form01`` in the -``[formatters]`` section will have its configuration specified in a section -called ``[formatter_form01]``. The root logger configuration must be specified -in a section called ``[logger_root]``. +The configuration file format understood by :func:`fileConfig` is +based on :mod:`configparser` functionality. The file must contain +sections called ``[loggers]``, ``[handlers]`` and ``[formatters]`` +which identify by name the entities of each type which are defined in +the file. For each such entity, there is a separate section which +identified how that entity is configured. Thus, for a logger named +``log01`` in the ``[loggers]`` section, the relevant configuration +details are held in a section ``[logger_log01]``. Similarly, a handler +called ``hand01`` in the ``[handlers]`` section will have its +configuration held in a section called ``[handler_hand01]``, while a +formatter called ``form01`` in the ``[formatters]`` section will have +its configuration specified in a section called +``[formatter_form01]``. The root logger configuration must be +specified in a section called ``[logger_root]``. Examples of these sections in the file are given below. :: |