Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1d1eaa4

Browse files
committed
Renamed ConfigParser to configparser.
Merged revisions 63247-63248 via svnmerge from svn+ssh://[email protected]/python/trunk ........ r63247 | georg.brandl | 2008-05-14 18:30:31 -0400 (Wed, 14 May 2008) | 2 lines Update configparser docs for lowercasing rename. ........ r63248 | alexandre.vassalotti | 2008-05-14 18:44:22 -0400 (Wed, 14 May 2008) | 8 lines 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. ........
1 parent 84726fa commit 1d1eaa4

11 files changed

Lines changed: 61 additions & 58 deletions

File tree

Doc/library/configparser.rst

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
2-
:mod:`ConfigParser` --- Configuration file parser
1+
:mod:`configparser` --- Configuration file parser
32
=================================================
43

5-
.. module:: ConfigParser
4+
.. module:: configparser
65
:synopsis: Configuration file parser.
6+
77
.. moduleauthor:: Ken Manheimer <[email protected]>
88
.. moduleauthor:: Barry Warsaw <[email protected]>
99
.. moduleauthor:: Eric S. Raymond <[email protected]>
1010
.. sectionauthor:: Christopher G. Petrilli <[email protected]>
1111

12-
1312
.. index::
1413
pair: .ini; file
1514
pair: configuration; file
@@ -213,9 +212,9 @@ RawConfigParser Objects
213212
load the required file or files using :meth:`readfp` before calling :meth:`read`
214213
for any optional files::
215214

216-
import ConfigParser, os
215+
import configparser, os
217216

218-
config = ConfigParser.ConfigParser()
217+
config = configparser.ConfigParser()
219218
config.readfp(open('defaults.cfg'))
220219
config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')])
221220

@@ -342,9 +341,9 @@ Examples
342341

343342
An example of writing to a configuration file::
344343

345-
import ConfigParser
344+
import configparser
346345

347-
config = ConfigParser.RawConfigParser()
346+
config = configparser.RawConfigParser()
348347
349348
# When adding sections or items, add them in the reverse order of
350349
# how you want them to be displayed in the actual file.
@@ -367,9 +366,9 @@ An example of writing to a configuration file::
367366

368367
An example of reading the configuration file again::
369368

370-
import ConfigParser
369+
import configparser
371370

372-
config = ConfigParser.RawConfigParser()
371+
config = configparser.RawConfigParser()
373372
config.read('example.cfg')
374373

375374
# getfloat() raises an exception if the value is not a float
@@ -386,9 +385,9 @@ An example of reading the configuration file again::
386385
To get interpolation, you will need to use a :class:`ConfigParser` or
387386
:class:`SafeConfigParser`::
388387

389-
import ConfigParser
388+
import configparser
390389

391-
config = ConfigParser.ConfigParser()
390+
config = configparser.ConfigParser()
392391
config.read('example.cfg')
393392

394393
# Set the third, optional argument of get to 1 if you wish to use raw mode.
@@ -403,10 +402,10 @@ To get interpolation, you will need to use a :class:`ConfigParser` or
403402
Defaults are available in all three types of ConfigParsers. They are used in
404403
interpolation if an option used is not defined elsewhere. ::
405404

406-
import ConfigParser
405+
import configparser
407406

408407
# New instance with 'bar' and 'baz' defaulting to 'Life' and 'hard' each
409-
config = ConfigParser.SafeConfigParser({'bar': 'Life', 'baz': 'hard'})
408+
config = configparser.SafeConfigParser({'bar': 'Life', 'baz': 'hard'})
410409
config.read('example.cfg')
411410
412411
print(config.get('Section1', 'foo')) # -> "Python is fun!"
@@ -419,7 +418,7 @@ The function ``opt_move`` below can be used to move options between sections::
419418
def opt_move(config, section1, section2, option):
420419
try:
421420
config.set(section2, option, config.get(section1, option, 1))
422-
except ConfigParser.NoSectionError:
421+
except configparser.NoSectionError:
423422
# Create non-existent section
424423
config.add_section(section2)
425424
opt_move(config, section1, section2, option)

Doc/library/logging.rst

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,12 +2202,12 @@ in :mod:`logging` itself) and defining handlers which are declared either in
22022202

22032203
.. function:: fileConfig(fname[, defaults])
22042204

2205-
Reads the logging configuration from a ConfigParser-format file named *fname*.
2206-
This function can be called several times from an application, allowing an end
2207-
user the ability to select from various pre-canned configurations (if the
2208-
developer provides a mechanism to present the choices and load the chosen
2209-
configuration). Defaults to be passed to ConfigParser can be specified in the
2210-
*defaults* argument.
2205+
Reads the logging configuration from a :mod:`configparser`\-format file named
2206+
*fname*. This function can be called several times from an application,
2207+
allowing an end user the ability to select from various pre-canned
2208+
configurations (if the developer provides a mechanism to present the choices
2209+
and load the chosen configuration). Defaults to be passed to the ConfigParser
2210+
can be specified in the *defaults* argument.
22112211

22122212

22132213
.. function:: listen([port])
@@ -2237,18 +2237,20 @@ in :mod:`logging` itself) and defining handlers which are declared either in
22372237
Configuration file format
22382238
^^^^^^^^^^^^^^^^^^^^^^^^^
22392239

2240-
The configuration file format understood by :func:`fileConfig` is based on
2241-
ConfigParser functionality. The file must contain sections called ``[loggers]``,
2242-
``[handlers]`` and ``[formatters]`` which identify by name the entities of each
2243-
type which are defined in the file. For each such entity, there is a separate
2244-
section which identified how that entity is configured. Thus, for a logger named
2245-
``log01`` in the ``[loggers]`` section, the relevant configuration details are
2246-
held in a section ``[logger_log01]``. Similarly, a handler called ``hand01`` in
2247-
the ``[handlers]`` section will have its configuration held in a section called
2248-
``[handler_hand01]``, while a formatter called ``form01`` in the
2249-
``[formatters]`` section will have its configuration specified in a section
2250-
called ``[formatter_form01]``. The root logger configuration must be specified
2251-
in a section called ``[logger_root]``.
2240+
The configuration file format understood by :func:`fileConfig` is
2241+
based on :mod:`configparser` functionality. The file must contain
2242+
sections called ``[loggers]``, ``[handlers]`` and ``[formatters]``
2243+
which identify by name the entities of each type which are defined in
2244+
the file. For each such entity, there is a separate section which
2245+
identified how that entity is configured. Thus, for a logger named
2246+
``log01`` in the ``[loggers]`` section, the relevant configuration
2247+
details are held in a section ``[logger_log01]``. Similarly, a handler
2248+
called ``hand01`` in the ``[handlers]`` section will have its
2249+
configuration held in a section called ``[handler_hand01]``, while a
2250+
formatter called ``form01`` in the ``[formatters]`` section will have
2251+
its configuration specified in a section called
2252+
``[formatter_form01]``. The root logger configuration must be
2253+
specified in a section called ``[logger_root]``.
22522254

22532255
Examples of these sections in the file are given below. ::
22542256

Doc/library/shlex.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The :mod:`shlex` module defines the following class:
5555

5656
.. seealso::
5757

58-
Module :mod:`ConfigParser`
58+
Module :mod:`configparser`
5959
Parser for configuration files similar to the Windows :file:`.ini` files.
6060

6161

File renamed without changes.

Lib/distutils/command/upload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import os
1111
import socket
1212
import platform
13-
import ConfigParser
13+
import configparser
1414
import httplib
1515
import base64
1616
import urlparse

Lib/distutils/dist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def find_config_files (self):
349349

350350
def parse_config_files (self, filenames=None):
351351

352-
from ConfigParser import ConfigParser
352+
from configparser import ConfigParser
353353

354354
if filenames is None:
355355
filenames = self.find_config_files()

Lib/idlelib/configHandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import sys
2222

2323
from idlelib import macosxSupport
24-
from ConfigParser import ConfigParser, NoOptionError, NoSectionError
24+
from configparser import ConfigParser, NoOptionError, NoSectionError
2525

2626
class InvalidConfigType(Exception): pass
2727
class InvalidConfigSet(Exception): pass

Lib/logging/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ def fileConfig(fname, defaults=None):
6262
rather than a filename, in which case the file-like object will be read
6363
using readfp.
6464
"""
65-
import ConfigParser
65+
import configparser
6666

67-
cp = ConfigParser.ConfigParser(defaults)
67+
cp = configparser.ConfigParser(defaults)
6868
if hasattr(cp, 'readfp') and hasattr(fname, 'readline'):
6969
cp.readfp(fname)
7070
else:

Lib/test/test___all__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_all(self):
3434

3535
self.check_all("BaseHTTPServer")
3636
self.check_all("CGIHTTPServer")
37-
self.check_all("ConfigParser")
37+
self.check_all("configparser")
3838
self.check_all("Cookie")
3939
self.check_all("Queue")
4040
self.check_all("SimpleHTTPServer")

Lib/test/test_cfgparser.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ConfigParser
1+
import configparser
22
import io
33
import unittest
44
import collections
@@ -89,7 +89,7 @@ def test_basic(self):
8989
"remove_option() failed to report non-existance of option"
9090
" that was removed")
9191

92-
self.assertRaises(ConfigParser.NoSectionError,
92+
self.assertRaises(configparser.NoSectionError,
9393
cf.remove_option, 'No Such Section', 'foo')
9494

9595
eq(cf.get('Long Line', 'foo'),
@@ -142,17 +142,17 @@ def test_default_case_sensitivity(self):
142142

143143
def test_parse_errors(self):
144144
self.newconfig()
145-
self.parse_error(ConfigParser.ParsingError,
145+
self.parse_error(configparser.ParsingError,
146146
"[Foo]\n extra-spaces: splat\n")
147-
self.parse_error(ConfigParser.ParsingError,
147+
self.parse_error(configparser.ParsingError,
148148
"[Foo]\n extra-spaces= splat\n")
149-
self.parse_error(ConfigParser.ParsingError,
149+
self.parse_error(configparser.ParsingError,
150150
"[Foo]\noption-without-value\n")
151-
self.parse_error(ConfigParser.ParsingError,
151+
self.parse_error(configparser.ParsingError,
152152
"[Foo]\n:value-without-option-name\n")
153-
self.parse_error(ConfigParser.ParsingError,
153+
self.parse_error(configparser.ParsingError,
154154
"[Foo]\n=value-without-option-name\n")
155-
self.parse_error(ConfigParser.MissingSectionHeaderError,
155+
self.parse_error(configparser.MissingSectionHeaderError,
156156
"No Section!\n")
157157

158158
def parse_error(self, exc, src):
@@ -165,13 +165,13 @@ def test_query_errors(self):
165165
"new ConfigParser should have no defined sections")
166166
self.failIf(cf.has_section("Foo"),
167167
"new ConfigParser should have no acknowledged sections")
168-
self.assertRaises(ConfigParser.NoSectionError,
168+
self.assertRaises(configparser.NoSectionError,
169169
cf.options, "Foo")
170-
self.assertRaises(ConfigParser.NoSectionError,
170+
self.assertRaises(configparser.NoSectionError,
171171
cf.set, "foo", "bar", "value")
172-
self.get_error(ConfigParser.NoSectionError, "foo", "bar")
172+
self.get_error(configparser.NoSectionError, "foo", "bar")
173173
cf.add_section("foo")
174-
self.get_error(ConfigParser.NoOptionError, "foo", "bar")
174+
self.get_error(configparser.NoOptionError, "foo", "bar")
175175

176176
def get_error(self, exc, section, option):
177177
try:
@@ -210,7 +210,7 @@ def test_boolean(self):
210210
def test_weird_errors(self):
211211
cf = self.newconfig()
212212
cf.add_section("Foo")
213-
self.assertRaises(ConfigParser.DuplicateSectionError,
213+
self.assertRaises(configparser.DuplicateSectionError,
214214
cf.add_section, "Foo")
215215

216216
def test_write(self):
@@ -314,7 +314,7 @@ def check_items_config(self, expected):
314314

315315

316316
class ConfigParserTestCase(TestCaseBase):
317-
config_class = ConfigParser.ConfigParser
317+
config_class = configparser.ConfigParser
318318

319319
def test_interpolation(self):
320320
cf = self.get_interpolation_config()
@@ -325,11 +325,11 @@ def test_interpolation(self):
325325
"something with lots of interpolation (9 steps)")
326326
eq(cf.get("Foo", "bar10"),
327327
"something with lots of interpolation (10 steps)")
328-
self.get_error(ConfigParser.InterpolationDepthError, "Foo", "bar11")
328+
self.get_error(configparser.InterpolationDepthError, "Foo", "bar11")
329329

330330
def test_interpolation_missing_value(self):
331331
cf = self.get_interpolation_config()
332-
e = self.get_error(ConfigParser.InterpolationError,
332+
e = self.get_error(configparser.InterpolationError,
333333
"Interpolation Error", "name")
334334
self.assertEqual(e.reference, "reference")
335335
self.assertEqual(e.section, "Interpolation Error")
@@ -365,7 +365,7 @@ def test_set_nonstring_types(self):
365365

366366

367367
class RawConfigParserTestCase(TestCaseBase):
368-
config_class = ConfigParser.RawConfigParser
368+
config_class = configparser.RawConfigParser
369369

370370
def test_interpolation(self):
371371
cf = self.get_interpolation_config()
@@ -400,7 +400,7 @@ def test_set_nonstring_types(self):
400400

401401

402402
class SafeConfigParserTestCase(ConfigParserTestCase):
403-
config_class = ConfigParser.SafeConfigParser
403+
config_class = configparser.SafeConfigParser
404404

405405
def test_safe_interpolation(self):
406406
# See http://www.python.org/sf/511737

0 commit comments

Comments
 (0)