]> granicus.if.org Git - python/commitdiff
Updated import statements to use the new `configparser` module name.
authorAlexandre Vassalotti <alexandre@peadrop.com>
Wed, 14 May 2008 22:44:22 +0000 (22:44 +0000)
committerAlexandre Vassalotti <alexandre@peadrop.com>
Wed, 14 May 2008 22:44:22 +0000 (22:44 +0000)
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.

Doc/library/configparser.rst
Doc/library/logging.rst
Lib/distutils/command/upload.py
Lib/distutils/config.py
Lib/distutils/dist.py
Lib/idlelib/configHandler.py
Lib/logging/config.py
Lib/test/test___all__.py
Lib/test/test_cfgparser.py

index 50373fc1483da5b493cc31b5419b2f25a29e7195..fe811debbd6b65a3797a959e5675b55b338f0ca2 100644 (file)
@@ -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)
index b2686aa6c2355ece6e0ca95d3288edf88249cb92..6ece996bc90cd7a9330bfd87d8c067754f6f81c2 100644 (file)
@@ -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. ::
 
index daf681128d74278a2e82360ff8a573c5ed621c90..ecc06f05ec4741b5acc15ecc8cbdb4d27caa5a7e 100644 (file)
@@ -10,7 +10,7 @@ from hashlib import md5
 import os
 import socket
 import platform
-import ConfigParser
+import configparser
 import httplib
 import base64
 import urlparse
index cf547698a90f231a95447e419f4d4aaba1afb6ff..e9ba40260cafda26526798f0fa8ce5a7ee0e31d1 100644 (file)
@@ -5,7 +5,7 @@ that uses .pypirc in the distutils.command package.
 """
 import os
 import sys
-from ConfigParser import ConfigParser
+from configparser import ConfigParser
 
 from distutils.core import Command
 
index 0b13c1e6c19261f540960f5368eb87891d2d261c..e4ab3363d877f1883c51a6435142c720e3721a94 100644 (file)
@@ -359,7 +359,7 @@ Common commands: (see '--help-commands' for more)
 
     def parse_config_files (self, filenames=None):
 
-        from ConfigParser import ConfigParser
+        from configparser import ConfigParser
 
         if filenames is None:
             filenames = self.find_config_files()
index 3fc2a606fe615fd05512eb95a84fe44530cd65da..bdce85d36c19e26485b068de5c79eab9d46cf1b1 100644 (file)
@@ -21,7 +21,7 @@ import os
 import sys
 import string
 import macosxSupport
-from ConfigParser import ConfigParser, NoOptionError, NoSectionError
+from configparser import ConfigParser, NoOptionError, NoSectionError
 
 class InvalidConfigType(Exception): pass
 class InvalidConfigSet(Exception): pass
index 33d6f2f27a5be4858db929227862a43bb5fef4ba..b4c52b46dc49f8163af98f94d2276ddb48ced562 100644 (file)
@@ -65,9 +65,9 @@ def fileConfig(fname, defaults=None):
     rather than a filename, in which case the file-like object will be read
     using readfp.
     """
-    import ConfigParser
+    import configparser
 
-    cp = ConfigParser.ConfigParser(defaults)
+    cp = configparser.ConfigParser(defaults)
     if hasattr(cp, 'readfp') and hasattr(fname, 'readline'):
         cp.readfp(fname)
     else:
index 8d3e9eea438740bdf83bb1504b30271b82649e26..63df10a6615ac28c2a7b35c8ce8d40b3a9d8769f 100644 (file)
@@ -37,7 +37,7 @@ class AllTest(unittest.TestCase):
         self.check_all("BaseHTTPServer")
         self.check_all("Bastion")
         self.check_all("CGIHTTPServer")
-        self.check_all("ConfigParser")
+        self.check_all("configparser")
         self.check_all("Cookie")
         self.check_all("MimeWriter")
         self.check_all("Queue")
index a8b5d7c389ad4ed48a5db1bda3668173c8b2199b..4dfa79522dfe1bffc8285c302dbe7e90da9b730f 100644 (file)
@@ -1,4 +1,4 @@
-import ConfigParser
+import configparser
 import StringIO
 import unittest
 import UserDict
@@ -94,7 +94,7 @@ class TestCaseBase(unittest.TestCase):
                     "remove_option() failed to report non-existance of option"
                     " that was removed")
 
-        self.assertRaises(ConfigParser.NoSectionError,
+        self.assertRaises(configparser.NoSectionError,
                           cf.remove_option, 'No Such Section', 'foo')
 
         eq(cf.get('Long Line', 'foo'),
@@ -147,17 +147,17 @@ class TestCaseBase(unittest.TestCase):
 
     def test_parse_errors(self):
         self.newconfig()
-        self.parse_error(ConfigParser.ParsingError,
+        self.parse_error(configparser.ParsingError,
                          "[Foo]\n  extra-spaces: splat\n")
-        self.parse_error(ConfigParser.ParsingError,
+        self.parse_error(configparser.ParsingError,
                          "[Foo]\n  extra-spaces= splat\n")
-        self.parse_error(ConfigParser.ParsingError,
+        self.parse_error(configparser.ParsingError,
                          "[Foo]\noption-without-value\n")
-        self.parse_error(ConfigParser.ParsingError,
+        self.parse_error(configparser.ParsingError,
                          "[Foo]\n:value-without-option-name\n")
-        self.parse_error(ConfigParser.ParsingError,
+        self.parse_error(configparser.ParsingError,
                          "[Foo]\n=value-without-option-name\n")
-        self.parse_error(ConfigParser.MissingSectionHeaderError,
+        self.parse_error(configparser.MissingSectionHeaderError,
                          "No Section!\n")
 
     def parse_error(self, exc, src):
@@ -170,13 +170,13 @@ class TestCaseBase(unittest.TestCase):
                          "new ConfigParser should have no defined sections")
         self.failIf(cf.has_section("Foo"),
                     "new ConfigParser should have no acknowledged sections")
-        self.assertRaises(ConfigParser.NoSectionError,
+        self.assertRaises(configparser.NoSectionError,
                           cf.options, "Foo")
-        self.assertRaises(ConfigParser.NoSectionError,
+        self.assertRaises(configparser.NoSectionError,
                           cf.set, "foo", "bar", "value")
-        self.get_error(ConfigParser.NoSectionError, "foo", "bar")
+        self.get_error(configparser.NoSectionError, "foo", "bar")
         cf.add_section("foo")
-        self.get_error(ConfigParser.NoOptionError, "foo", "bar")
+        self.get_error(configparser.NoOptionError, "foo", "bar")
 
     def get_error(self, exc, section, option):
         try:
@@ -215,7 +215,7 @@ class TestCaseBase(unittest.TestCase):
     def test_weird_errors(self):
         cf = self.newconfig()
         cf.add_section("Foo")
-        self.assertRaises(ConfigParser.DuplicateSectionError,
+        self.assertRaises(configparser.DuplicateSectionError,
                           cf.add_section, "Foo")
 
     def test_write(self):
@@ -324,7 +324,7 @@ class TestCaseBase(unittest.TestCase):
 
 
 class ConfigParserTestCase(TestCaseBase):
-    config_class = ConfigParser.ConfigParser
+    config_class = configparser.ConfigParser
 
     def test_interpolation(self):
         cf = self.get_interpolation_config()
@@ -335,11 +335,11 @@ class ConfigParserTestCase(TestCaseBase):
            "something with lots of interpolation (9 steps)")
         eq(cf.get("Foo", "bar10"),
            "something with lots of interpolation (10 steps)")
-        self.get_error(ConfigParser.InterpolationDepthError, "Foo", "bar11")
+        self.get_error(configparser.InterpolationDepthError, "Foo", "bar11")
 
     def test_interpolation_missing_value(self):
         cf = self.get_interpolation_config()
-        e = self.get_error(ConfigParser.InterpolationError,
+        e = self.get_error(configparser.InterpolationError,
                            "Interpolation Error", "name")
         self.assertEqual(e.reference, "reference")
         self.assertEqual(e.section, "Interpolation Error")
@@ -375,7 +375,7 @@ class ConfigParserTestCase(TestCaseBase):
 
 
 class RawConfigParserTestCase(TestCaseBase):
-    config_class = ConfigParser.RawConfigParser
+    config_class = configparser.RawConfigParser
 
     def test_interpolation(self):
         cf = self.get_interpolation_config()
@@ -410,7 +410,7 @@ class RawConfigParserTestCase(TestCaseBase):
 
 
 class SafeConfigParserTestCase(ConfigParserTestCase):
-    config_class = ConfigParser.SafeConfigParser
+    config_class = configparser.SafeConfigParser
 
     def test_safe_interpolation(self):
         # See http://www.python.org/sf/511737