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
a5a24b76
Commit
a5a24b76
authored
Oct 04, 1999
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added has_option(); fix bug in get() which botched interpolation if
'%(' was found in first position (found by Fred Drake).
parent
6a8d84b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
Lib/ConfigParser.py
Lib/ConfigParser.py
+16
-1
No files found.
Lib/ConfigParser.py
View file @
a5a24b76
...
...
@@ -33,9 +33,15 @@ ConfigParser -- responsible for for parsing a list of
sections()
return all the configuration section names, sans DEFAULT
has_section(section)
return whether the given section exists
options(section)
return list of configuration options for the named section
has_option(section, option)
return whether the given section has the given option
read(filenames)
read and parse the list of named configuration files, given by
name. A single filename is also allowed. Non-existing files
...
...
@@ -165,6 +171,7 @@ class ConfigParser:
return
self
.
__sections
.
has_key
(
section
)
def
options
(
self
,
section
):
"""Return a list of option names for the given section name."""
try
:
opts
=
self
.
__sections
[
section
].
copy
()
except
KeyError
:
...
...
@@ -172,6 +179,14 @@ class ConfigParser:
opts
.
update
(
self
.
__defaults
)
return
opts
.
keys
()
def
has_option
(
self
,
section
,
option
):
"""Return whether the given section has the given option."""
try
:
opts
=
self
.
__sections
[
section
]
except
KeyError
:
raise
NoSectionError
(
section
)
return
opts
.
has_key
(
option
)
def
read
(
self
,
filenames
):
"""Read and parse a filename or a list of filenames.
...
...
@@ -245,7 +260,7 @@ class ConfigParser:
depth
=
0
while
depth
<
10
:
# Loop through this until it's done
depth
=
depth
+
1
if
not
string
.
find
(
value
,
"%("
)
:
if
string
.
find
(
value
,
"%("
)
>=
0
:
try
:
value
=
value
%
d
except
KeyError
,
key
:
...
...
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