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
e0d06252
Commit
e0d06252
authored
Oct 25, 2002
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to reflect the refactoring into the RawConfigParser and
ConfigParser classes.
parent
dfc64c99
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
18 deletions
+41
-18
Doc/lib/libcfgparser.tex
Doc/lib/libcfgparser.tex
+41
-18
No files found.
Doc/lib/libcfgparser.tex
View file @
e0d06252
...
@@ -22,13 +22,14 @@ with continuations in the style of \rfc{822}; \samp{name=value} is
...
@@ -22,13 +22,14 @@ with continuations in the style of \rfc{822}; \samp{name=value} is
also accepted. Note that leading whitespace is removed from values.
also accepted. Note that leading whitespace is removed from values.
The optional values can contain format strings which refer to other
The optional values can contain format strings which refer to other
values in the same section, or values in a special
values in the same section, or values in a special
\code
{
DEFAULT
}
section. Additional defaults can be provided
up
on
\code
{
DEFAULT
}
section. Additional defaults can be provided on
initialization and retrieval. Lines beginning with
\character
{
\#
}
or
initialization and retrieval. Lines beginning with
\character
{
\#
}
or
\character
{
;
}
are ignored and may be used to provide comments.
\character
{
;
}
are ignored and may be used to provide comments.
For example:
For example:
\begin{verbatim}
\begin{verbatim}
[My Section]
foodir:
%(dir)s/whatever
foodir:
%(dir)s/whatever
dir=frob
dir=frob
\end{verbatim}
\end{verbatim}
...
@@ -42,10 +43,17 @@ Default values can be specified by passing them into the
...
@@ -42,10 +43,17 @@ Default values can be specified by passing them into the
may be passed into the
\method
{
get()
}
method which will override all
may be passed into the
\method
{
get()
}
method which will override all
others.
others.
\begin{classdesc}
{
RawConfigParser
}{
\optional
{
defaults
}}
The basic configuration object. When
\var
{
defaults
}
is given, it is
initialized into the dictionary of intrinsic defaults. This class
does not support the magical interpolation behavior.
\versionadded
{
2.3
}
\end{classdesc}
\begin{classdesc}
{
ConfigParser
}{
\optional
{
defaults
}}
\begin{classdesc}
{
ConfigParser
}{
\optional
{
defaults
}}
Return a new instance of the
\class
{
ConfigParser
}
class. When
Derived class of
\class
{
RawConfigParser
}
that implements the magical
\var
{
defaults
}
is given, it is initialized into the dictionary of
interpolation feature and adds optional arguments the
\method
{
get()
}
intrinsic defaults. The keys must be strings, and the values must be
and
\method
{
items()
}
methods. The values in
\var
{
defaults
}
must be
appropriate for the
\samp
{
\%
()s
}
string interpolation. Note that
appropriate for the
\samp
{
\%
()s
}
string interpolation. Note that
\var
{__
name
__}
is an intrinsic default; its value is the section name,
\var
{__
name
__}
is an intrinsic default; its value is the section name,
and will override any value provided in
\var
{
defaults
}
.
and will override any value provided in
\var
{
defaults
}
.
...
@@ -86,8 +94,8 @@ Exception raised when errors occur attempting to parse a file.
...
@@ -86,8 +94,8 @@ Exception raised when errors occur attempting to parse a file.
\begin{datadesc}
{
MAX
_
INTERPOLATION
_
DEPTH
}
\begin{datadesc}
{
MAX
_
INTERPOLATION
_
DEPTH
}
The maximum depth for recursive interpolation for
\method
{
get()
}
when
The maximum depth for recursive interpolation for
\method
{
get()
}
when
the
\var
{
raw
}
parameter is false.
Setting this does not change
the
the
\var
{
raw
}
parameter is false.
This is relevant only for
the
allowed recursion depth
.
\class
{
ConfigParser
}
class
.
\end{datadesc}
\end{datadesc}
...
@@ -98,9 +106,9 @@ allowed recursion depth.
...
@@ -98,9 +106,9 @@ allowed recursion depth.
\end{seealso}
\end{seealso}
\subsection
{
ConfigParser Objects
\label
{
ConfigParser-objects
}}
\subsection
{
RawConfigParser Objects
\label
{
Raw
ConfigParser-objects
}}
\class
{
ConfigParser
}
instances have the following methods:
\class
{
Raw
ConfigParser
}
instances have the following methods:
\begin{methoddesc}
{
defaults
}{}
\begin{methoddesc}
{
defaults
}{}
Return a dictionary containing the instance-wide defaults.
Return a dictionary containing the instance-wide defaults.
...
@@ -162,11 +170,8 @@ Read and parse configuration data from the file or file-like object in
...
@@ -162,11 +170,8 @@ Read and parse configuration data from the file or file-like object in
that is used for
\var
{
filename
}
; the default is
\samp
{
<???>
}
.
that is used for
\var
{
filename
}
; the default is
\samp
{
<???>
}
.
\end{methoddesc}
\end{methoddesc}
\begin{methoddesc}
{
get
}{
section, option
\optional
{
, raw
\optional
{
, vars
}}}
\begin{methoddesc}
{
get
}{
section, option
}
Get an
\var
{
option
}
value for the provided
\var
{
section
}
. All the
Get an
\var
{
option
}
value for the named
\var
{
section
}
.
\character
{
\%
}
interpolations are expanded in the return values, based on
the defaults passed into the constructor, as well as the options
\var
{
vars
}
provided, unless the
\var
{
raw
}
argument is true.
\end{methoddesc}
\end{methoddesc}
\begin{methoddesc}
{
getint
}{
section, option
}
\begin{methoddesc}
{
getint
}{
section, option
}
...
@@ -189,11 +194,9 @@ values are checked in a case-insensitive manner. Any other value will
...
@@ -189,11 +194,9 @@ values are checked in a case-insensitive manner. Any other value will
cause it to raise
\exception
{
ValueError
}
.
cause it to raise
\exception
{
ValueError
}
.
\end{methoddesc}
\end{methoddesc}
\begin{methoddesc}
{
items
}{
section
\optional
{
, raw
\optional
{
, vars
}}}
\begin{methoddesc}
{
items
}{
section
}
Create a generator which will return a tuple
\code
{
(name, value)
}
for
Return a list of
\code
{
(
\var
{
name
}
,
\var
{
value
}
)
}
pairs for each
each option in the given
\var
{
section
}
. Optional arguments have the
option in the given
\var
{
section
}
.
same meaning as for the
\code
{
get()
}
method.
\versionadded
{
2.3
}
\end{methoddesc}
\end{methoddesc}
\begin{methoddesc}
{
set
}{
section, option, value
}
\begin{methoddesc}
{
set
}{
section, option, value
}
...
@@ -231,3 +234,23 @@ can set an attribute of this name on instances to affect this
...
@@ -231,3 +234,23 @@ can set an attribute of this name on instances to affect this
behavior. Setting this to
\function
{
str()
}
, for example, would make
behavior. Setting this to
\function
{
str()
}
, for example, would make
option names case sensitive.
option names case sensitive.
\end{methoddesc}
\end{methoddesc}
\subsection
{
ConfigParser Objects
\label
{
ConfigParser-objects
}}
The
\class
{
ConfigParser
}
class extends some methods of the
\class
{
RawConfigParser
}
interface, adding some optional arguments.
\begin{methoddesc}
{
get
}{
section, option
\optional
{
, raw
\optional
{
, vars
}}}
Get an
\var
{
option
}
value for the named
\var
{
section
}
. All the
\character
{
\%
}
interpolations are expanded in the return values, based
on the defaults passed into the constructor, as well as the options
\var
{
vars
}
provided, unless the
\var
{
raw
}
argument is true.
\end{methoddesc}
\begin{methoddesc}
{
items
}{
section
\optional
{
, raw
\optional
{
, vars
}}}
Create a generator which will return a tuple
\code
{
(name, value)
}
for
each option in the given
\var
{
section
}
. Optional arguments have the
same meaning as for the
\code
{
get()
}
method.
\versionadded
{
2.3
}
\end{methoddesc}
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