summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-05-25 07:25:25 (GMT)
committerGeorg Brandl <georg@python.org>2008-05-25 07:25:25 (GMT)
commit392c6fc02d90f211dadc72448a07d9281260cb70 (patch)
tree8cc4d563ee077ef83612a67a02ce36f5c2397d37 /Doc
parent995ee9dab0a89b139e08a55fc64a60aaddc0d5c0 (diff)
downloadcpython-392c6fc02d90f211dadc72448a07d9281260cb70.zip
cpython-392c6fc02d90f211dadc72448a07d9281260cb70.tar.gz
cpython-392c6fc02d90f211dadc72448a07d9281260cb70.tar.bz2
ConfigParser renaming reversal part 3: move module into place and adapt imports.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/configparser.rst42
-rw-r--r--Doc/library/logging.rst38
-rw-r--r--Doc/library/shlex.rst2
3 files changed, 39 insertions, 43 deletions
diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst
index 6a4e049..ec9aec2 100644
--- a/Doc/library/configparser.rst
+++ b/Doc/library/configparser.rst
@@ -1,10 +1,7 @@
-: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>
@@ -13,9 +10,10 @@
.. 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.
+
+ The :mod:`ConfigParser` module has been renamed to `configparser` in Python
+ 3.0. The :term:`2to3` tool will automatically adapt imports when converting
+ your sources to 3.0.
.. index::
pair: .ini; file
@@ -233,9 +231,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')])
@@ -375,10 +373,10 @@ 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.
# In addition, please note that using RawConfigParser's and the raw
@@ -393,16 +391,16 @@ An example of writing to a configuration file::
config.set('Section1', 'baz', 'fun')
config.set('Section1', 'bar', 'Python')
config.set('Section1', 'foo', '%(bar)s is %(baz)s!')
-
+
# Writing our configuration file to 'example.cfg'
with open('example.cfg', 'wb') as configfile:
config.write(configfile)
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
@@ -419,9 +417,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.
@@ -433,15 +431,15 @@ To get interpolation, you will need to use a :class:`ConfigParser` or
print config.get('Section1', 'foo', 0, {'bar': 'Documentation',
'baz': 'evil'})
-Defaults are available in all three types of ConfigParsers. They are used in
+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!"
config.remove_option('Section1', 'bar')
config.remove_option('Section1', 'baz')
@@ -452,7 +450,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 bca1ece..1f7c59b 100644
--- a/Doc/library/logging.rst
+++ b/Doc/library/logging.rst
@@ -2240,12 +2240,12 @@ in :mod:`logging` itself) and defining handlers which are declared either in
.. function:: fileConfig(fname[, defaults])
- Reads the logging configuration from a :mod:`configparser`\-format file named
- *fname*. This function can be called several times from an application,
- allowing an end user the ability to select from various pre-canned
- configurations (if the developer provides a mechanism to present the choices
- and load the chosen configuration). Defaults to be passed to the ConfigParser
- can be specified in the *defaults* argument.
+ Reads the logging configuration from a ConfigParser-format file named *fname*.
+ This function can be called several times from an application, allowing an end
+ user the ability to select from various pre-canned configurations (if the
+ developer provides a mechanism to present the choices and load the chosen
+ configuration). Defaults to be passed to ConfigParser can be specified in the
+ *defaults* argument.
.. function:: listen([port])
@@ -2275,20 +2275,18 @@ 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 :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]``.
+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]``.
Examples of these sections in the file are given below. ::
diff --git a/Doc/library/shlex.rst b/Doc/library/shlex.rst
index 1dfafbd..0ae77c1 100644
--- a/Doc/library/shlex.rst
+++ b/Doc/library/shlex.rst
@@ -63,7 +63,7 @@ The :mod:`shlex` module defines the following class:
.. seealso::
- Module :mod:`configparser`
+ Module :mod:`ConfigParser`
Parser for configuration files similar to the Windows :file:`.ini` files.