Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
392c6fc0
Commit
392c6fc0
authored
May 25, 2008
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ConfigParser renaming reversal part 3: move module into place and adapt imports.
parent
995ee9da
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
68 additions
and
126 deletions
+68
-126
Doc/library/configparser.rst
Doc/library/configparser.rst
+20
-22
Doc/library/logging.rst
Doc/library/logging.rst
+18
-20
Doc/library/shlex.rst
Doc/library/shlex.rst
+1
-1
Lib/ConfigParser.py
Lib/ConfigParser.py
+0
-0
Lib/distutils/command/upload.py
Lib/distutils/command/upload.py
+1
-5
Lib/distutils/config.py
Lib/distutils/config.py
+1
-5
Lib/distutils/dist.py
Lib/distutils/dist.py
+1
-5
Lib/idlelib/configHandler.py
Lib/idlelib/configHandler.py
+1
-1
Lib/logging/config.py
Lib/logging/config.py
+2
-2
Lib/test/test___all__.py
Lib/test/test___all__.py
+1
-1
Lib/test/test_cfgparser.py
Lib/test/test_cfgparser.py
+18
-18
Lib/test/test_py3kwarn.py
Lib/test/test_py3kwarn.py
+1
-40
Misc/NEWS
Misc/NEWS
+2
-5
Misc/cheatsheet
Misc/cheatsheet
+1
-1
No files found.
Doc/library/configparser.rst
View file @
392c6fc0
:mod:`
configp
arser` --- Configuration file parser
:mod:`
ConfigP
arser` --- 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
configp
arser, os
import
ConfigP
arser, os
config =
configp
arser.ConfigParser()
config =
ConfigP
arser.ConfigParser()
config.readfp(open('defaults.cfg'))
config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')])
...
...
@@ -375,9 +373,9 @@ Examples
An example of writing to a configuration file::
import
configp
arser
import
ConfigP
arser
config =
configp
arser.RawConfigParser()
config =
ConfigP
arser.RawConfigParser()
# When adding sections or items, add them in the reverse order of
# how you want them to be displayed in the actual file.
...
...
@@ -400,9 +398,9 @@ An example of writing to a configuration file::
An example of reading the configuration file again::
import
configp
arser
import
ConfigP
arser
config =
configp
arser.RawConfigParser()
config =
ConfigP
arser.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
configp
arser
import
ConfigP
arser
config =
configp
arser.ConfigParser()
config =
ConfigP
arser.ConfigParser()
config.read('example.cfg')
# Set the third, optional argument of get to 1 if you wish to use raw mode.
...
...
@@ -436,10 +434,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
configp
arser
import
ConfigP
arser
# New instance with 'bar' and 'baz' defaulting to 'Life' and 'hard' each
config =
configp
arser.SafeConfigParser({'bar': 'Life', 'baz': 'hard'})
config =
ConfigP
arser.SafeConfigParser({'bar': 'Life', 'baz': 'hard'})
config.read('example.cfg')
print config.get('Section1', 'foo') # -> "Python is fun!"
...
...
@@ -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
configp
arser.NoSectionError:
except
ConfigP
arser.NoSectionError:
# Create non-existent section
config.add_section(section2)
opt_move(config, section1, section2, option)
...
...
Doc/library/logging.rst
View file @
392c6fc0
...
...
@@ -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
.
::
...
...
Doc/library/shlex.rst
View file @
392c6fc0
...
...
@@ -63,7 +63,7 @@ The :mod:`shlex` module defines the following class:
.. seealso::
Module :mod:`
configp
arser`
Module :mod:`
ConfigP
arser`
Parser for configuration files similar to the Windows :file:`.ini` files.
...
...
Lib/
lib-old/
ConfigParser.py
→
Lib/ConfigParser.py
View file @
392c6fc0
File moved
Lib/distutils/command/upload.py
View file @
392c6fc0
...
...
@@ -14,11 +14,7 @@ import httplib
import
base64
import
urlparse
import
cStringIO
as
StringIO
try
:
from
configparser
import
ConfigParser
except
ImportError
:
# For backward-compatibility with Python versions < 2.6.
from
ConfigParser
import
ConfigParser
from
ConfigParser
import
ConfigParser
class
upload
(
PyPIRCCommand
):
...
...
Lib/distutils/config.py
View file @
392c6fc0
...
...
@@ -5,11 +5,7 @@ that uses .pypirc in the distutils.command package.
"""
import
os
import
sys
try
:
from
configparser
import
ConfigParser
except
ImportError
:
# For backward-compatibility with Python versions < 2.6.
from
ConfigParser
import
ConfigParser
from
ConfigParser
import
ConfigParser
from
distutils.cmd
import
Command
...
...
Lib/distutils/dist.py
View file @
392c6fc0
...
...
@@ -358,10 +358,6 @@ Common commands: (see '--help-commands' for more)
def
parse_config_files
(
self
,
filenames
=
None
):
try
:
from
configparser
import
ConfigParser
except
ImportError
:
# For backward-compatibility with Python versions < 2.6.
from
ConfigParser
import
ConfigParser
if
filenames
is
None
:
...
...
Lib/idlelib/configHandler.py
View file @
392c6fc0
...
...
@@ -21,7 +21,7 @@ import os
import
sys
import
string
import
macosxSupport
from
configp
arser
import
ConfigParser
,
NoOptionError
,
NoSectionError
from
ConfigP
arser
import
ConfigParser
,
NoOptionError
,
NoSectionError
class
InvalidConfigType
(
Exception
):
pass
class
InvalidConfigSet
(
Exception
):
pass
...
...
Lib/logging/config.py
View file @
392c6fc0
...
...
@@ -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
configp
arser
import
ConfigP
arser
cp
=
configp
arser
.
ConfigParser
(
defaults
)
cp
=
ConfigP
arser
.
ConfigParser
(
defaults
)
if
hasattr
(
cp
,
'readfp'
)
and
hasattr
(
fname
,
'readline'
):
cp
.
readfp
(
fname
)
else
:
...
...
Lib/test/test___all__.py
View file @
392c6fc0
...
...
@@ -37,7 +37,7 @@ class AllTest(unittest.TestCase):
self
.
check_all
(
"BaseHTTPServer"
)
self
.
check_all
(
"Bastion"
)
self
.
check_all
(
"CGIHTTPServer"
)
self
.
check_all
(
"
configp
arser"
)
self
.
check_all
(
"
ConfigP
arser"
)
self
.
check_all
(
"Cookie"
)
self
.
check_all
(
"MimeWriter"
)
self
.
check_all
(
"Queue"
)
...
...
Lib/test/test_cfgparser.py
View file @
392c6fc0
import
configp
arser
import
ConfigP
arser
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
(
configp
arser
.
NoSectionError
,
self
.
assertRaises
(
ConfigP
arser
.
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
(
configp
arser
.
ParsingError
,
self
.
parse_error
(
ConfigP
arser
.
ParsingError
,
"[Foo]
\
n
extra-spaces: splat
\
n
"
)
self
.
parse_error
(
configp
arser
.
ParsingError
,
self
.
parse_error
(
ConfigP
arser
.
ParsingError
,
"[Foo]
\
n
extra-spaces= splat
\
n
"
)
self
.
parse_error
(
configp
arser
.
ParsingError
,
self
.
parse_error
(
ConfigP
arser
.
ParsingError
,
"[Foo]
\
n
option-without-value
\
n
"
)
self
.
parse_error
(
configp
arser
.
ParsingError
,
self
.
parse_error
(
ConfigP
arser
.
ParsingError
,
"[Foo]
\
n
:value-without-option-name
\
n
"
)
self
.
parse_error
(
configp
arser
.
ParsingError
,
self
.
parse_error
(
ConfigP
arser
.
ParsingError
,
"[Foo]
\
n
=value-without-option-name
\
n
"
)
self
.
parse_error
(
configp
arser
.
MissingSectionHeaderError
,
self
.
parse_error
(
ConfigP
arser
.
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
(
configp
arser
.
NoSectionError
,
self
.
assertRaises
(
ConfigP
arser
.
NoSectionError
,
cf
.
options
,
"Foo"
)
self
.
assertRaises
(
configp
arser
.
NoSectionError
,
self
.
assertRaises
(
ConfigP
arser
.
NoSectionError
,
cf
.
set
,
"foo"
,
"bar"
,
"value"
)
self
.
get_error
(
configp
arser
.
NoSectionError
,
"foo"
,
"bar"
)
self
.
get_error
(
ConfigP
arser
.
NoSectionError
,
"foo"
,
"bar"
)
cf
.
add_section
(
"foo"
)
self
.
get_error
(
configp
arser
.
NoOptionError
,
"foo"
,
"bar"
)
self
.
get_error
(
ConfigP
arser
.
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
(
configp
arser
.
DuplicateSectionError
,
self
.
assertRaises
(
ConfigP
arser
.
DuplicateSectionError
,
cf
.
add_section
,
"Foo"
)
def
test_write
(
self
):
...
...
@@ -324,7 +324,7 @@ class TestCaseBase(unittest.TestCase):
class
ConfigParserTestCase
(
TestCaseBase
):
config_class
=
configp
arser
.
ConfigParser
config_class
=
ConfigP
arser
.
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
(
configp
arser
.
InterpolationDepthError
,
"Foo"
,
"bar11"
)
self
.
get_error
(
ConfigP
arser
.
InterpolationDepthError
,
"Foo"
,
"bar11"
)
def
test_interpolation_missing_value
(
self
):
cf
=
self
.
get_interpolation_config
()
e
=
self
.
get_error
(
configp
arser
.
InterpolationError
,
e
=
self
.
get_error
(
ConfigP
arser
.
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
=
configp
arser
.
RawConfigParser
config_class
=
ConfigP
arser
.
RawConfigParser
def
test_interpolation
(
self
):
cf
=
self
.
get_interpolation_config
()
...
...
@@ -410,7 +410,7 @@ class RawConfigParserTestCase(TestCaseBase):
class
SafeConfigParserTestCase
(
ConfigParserTestCase
):
config_class
=
configp
arser
.
SafeConfigParser
config_class
=
ConfigP
arser
.
SafeConfigParser
def
test_safe_interpolation
(
self
):
# See http://www.python.org/sf/511737
...
...
Lib/test/test_py3kwarn.py
View file @
392c6fc0
...
...
@@ -213,48 +213,9 @@ class TestStdlibRemovals(unittest.TestCase):
self
.
assertEquals
(
str
(
w
.
message
),
msg
)
class
TestStdlibRenames
(
unittest
.
TestCase
):
renames
=
{
'ConfigParser'
:
'configparser'
}
def
check_rename
(
self
,
module_name
,
new_module_name
):
"""Make sure that:
- A DeprecationWarning is raised when importing using the
old 2.x module name.
- The module can be imported using the new 3.x name.
- The warning message specify both names.
"""
with
CleanImport
(
module_name
):
with
catch_warning
(
record
=
False
)
as
w
:
warnings
.
filterwarnings
(
"error"
,
".+ renamed to"
,
DeprecationWarning
)
try
:
__import__
(
module_name
,
level
=
0
)
except
DeprecationWarning
as
exc
:
self
.
assert_
(
module_name
in
exc
.
args
[
0
])
self
.
assert_
(
new_module_name
in
exc
.
args
[
0
])
else
:
self
.
fail
(
"DeprecationWarning not raised for %s"
%
module_name
)
with
CleanImport
(
new_module_name
):
try
:
__import__
(
new_module_name
,
level
=
0
)
except
ImportError
:
self
.
fail
(
"cannot import %s with its 3.x name, %s"
%
module_name
,
new_module_name
)
except
DeprecationWarning
:
self
.
fail
(
"unexpected DeprecationWarning raised for %s"
%
module_name
)
def
test_module_renames
(
self
):
for
module_name
,
new_module_name
in
self
.
renames
.
items
():
self
.
check_rename
(
module_name
,
new_module_name
)
def
test_main
():
run_unittest
(
TestPy3KWarnings
,
TestStdlibRemovals
,
TestStdlibRenames
)
TestStdlibRemovals
)
if
__name__
==
'__main__'
:
test_main
()
Misc/NEWS
View file @
392c6fc0
...
...
@@ -135,9 +135,6 @@ Library
- The DEVICE, GL, gl, and cgen modules (which indirectly includes
cgensupport) have been deprecated for removal in Python 3.0.
- The ConfigParser module has been renamed 'configparser'. The old
name is now deprecated.
- The CL, CL_old, and cl modules for IRIX have been deprecated for
removal in Python 3.0.
...
...
@@ -1904,13 +1901,13 @@ Library
Extension Modules
-----------------
- Patch #1657: added select.epoll and select.kqueue
- Patch #1657: added select.epoll and select.kqueue
.
- Patch #1506171: added operator.methodcaller().
- Patch #1826: operator.attrgetter() now supports dotted attribute paths.
- Patch #1957: syslogmodule: Release GIL when calling syslog(3)
- Patch #1957: syslogmodule: Release GIL when calling syslog(3)
.
- Bug #2112: mmap.error is now a subclass of EnvironmentError and not
a direct EnvironmentError.
...
...
Misc/cheatsheet
View file @
392c6fc0
...
...
@@ -1862,7 +1862,7 @@ codecs Lookup existing Unicode encodings and register new ones.
colorsys Conversion functions between RGB and other color systems.
commands Tools for executing UNIX commands .
compileall Force "compilation" of all .py files in a directory.
configp
arser Configuration file parser (much like windows .ini files)
ConfigP
arser Configuration file parser (much like windows .ini files)
copy Generic shallow and deep copying operations.
copy_reg Helper to provide extensibility for pickle/cPickle.
csv Read and write files with comma separated values.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment