annotate Doc/lib/libcfgparser.tex @ 27998:e27f58a50737 legacy-trunk

SF bug #690377: Dud footnote reference in distutils docs
author Raymond Hettinger <python@rcn.com>
date Fri, 21 Feb 2003 02:47:09 +0000
parents 776f270a6ea9
children 590d8ccabac7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
1 \section{\module{ConfigParser} ---
10648
48c33d05367f Markup nits.
Fred Drake <fdrake@acm.org>
parents: 10303
diff changeset
2 Configuration file parser}
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
3
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
4 \declaremodule{standard}{ConfigParser}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
5 \modulesynopsis{Configuration file parser.}
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
6 \moduleauthor{Ken Manheimer}{klm@digicool.com}
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
7 \moduleauthor{Barry Warsaw}{bwarsaw@python.org}
13521
4dbc75c189bc Give ConfigParser the capability to set as well as read options, and to write
Eric S. Raymond <esr@thyrsus.com>
parents: 12731
diff changeset
8 \moduleauthor{Eric S. Raymond}{esr@thyrsus.com}
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
9 \sectionauthor{Christopher G. Petrilli}{petrilli@amber.org}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
10
10988
7a127f1992d1 Several new index entries to make find this easier.
Fred Drake <fdrake@acm.org>
parents: 10844
diff changeset
11 This module defines the class \class{ConfigParser}.
7a127f1992d1 Several new index entries to make find this easier.
Fred Drake <fdrake@acm.org>
parents: 10844
diff changeset
12 \indexii{.ini}{file}\indexii{configuration}{file}\index{ini file}
7a127f1992d1 Several new index entries to make find this easier.
Fred Drake <fdrake@acm.org>
parents: 10844
diff changeset
13 \index{Windows ini file}
7a127f1992d1 Several new index entries to make find this easier.
Fred Drake <fdrake@acm.org>
parents: 10844
diff changeset
14 The \class{ConfigParser} class implements a basic configuration file
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
15 parser language which provides a structure similar to what you would
26908
bcaca36a583c - re-mark ESR's warning about extended registry syntax
Fred Drake <fdrake@acm.org>
parents: 26812
diff changeset
16 find on Microsoft Windows INI files. You can use this to write Python
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
17 programs which can be customized by end users easily.
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
18
26908
bcaca36a583c - re-mark ESR's warning about extended registry syntax
Fred Drake <fdrake@acm.org>
parents: 26812
diff changeset
19 \begin{notice}[warning]
bcaca36a583c - re-mark ESR's warning about extended registry syntax
Fred Drake <fdrake@acm.org>
parents: 26812
diff changeset
20 This library does \emph{not} interpret or write the value-type
bcaca36a583c - re-mark ESR's warning about extended registry syntax
Fred Drake <fdrake@acm.org>
parents: 26812
diff changeset
21 prefixes used in the Windows Registry extended version of INI syntax.
bcaca36a583c - re-mark ESR's warning about extended registry syntax
Fred Drake <fdrake@acm.org>
parents: 26812
diff changeset
22 \end{notice}
bcaca36a583c - re-mark ESR's warning about extended registry syntax
Fred Drake <fdrake@acm.org>
parents: 26812
diff changeset
23
26812
178844988812 Added a useful warning to the documentation.
Eric S. Raymond <esr@thyrsus.com>
parents: 25918
diff changeset
24 The configuration file consists of sections, led by a
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
25 \samp{[section]} header and followed by \samp{name: value} entries,
10988
7a127f1992d1 Several new index entries to make find this easier.
Fred Drake <fdrake@acm.org>
parents: 10844
diff changeset
26 with continuations in the style of \rfc{822}; \samp{name=value} is
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
27 also accepted. Note that leading whitespace is removed from values.
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
28 The optional values can contain format strings which refer to other
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
29 values in the same section, or values in a special
25913
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
30 \code{DEFAULT} section. Additional defaults can be provided on
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
31 initialization and retrieval. Lines beginning with \character{\#} or
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
32 \character{;} are ignored and may be used to provide comments.
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
33
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
34 For example:
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
35
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
36 \begin{verbatim}
25913
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
37 [My Section]
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
38 foodir: %(dir)s/whatever
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
39 dir=frob
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
40 \end{verbatim}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
41
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
42 would resolve the \samp{\%(dir)s} to the value of
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
43 \samp{dir} (\samp{frob} in this case). All reference expansions are
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
44 done on demand.
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
45
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
46 Default values can be specified by passing them into the
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
47 \class{ConfigParser} constructor as a dictionary. Additional defaults
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
48 may be passed into the \method{get()} method which will override all
9960
92a25d51ff26 Incorporate changes for patched version of ConfigParser.
Fred Drake <fdrake@acm.org>
parents: 9957
diff changeset
49 others.
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
50
25913
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
51 \begin{classdesc}{RawConfigParser}{\optional{defaults}}
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
52 The basic configuration object. When \var{defaults} is given, it is
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
53 initialized into the dictionary of intrinsic defaults. This class
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
54 does not support the magical interpolation behavior.
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
55 \versionadded{2.3}
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
56 \end{classdesc}
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
57
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
58 \begin{classdesc}{ConfigParser}{\optional{defaults}}
25913
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
59 Derived class of \class{RawConfigParser} that implements the magical
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
60 interpolation feature and adds optional arguments the \method{get()}
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
61 and \method{items()} methods. The values in \var{defaults} must be
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
62 appropriate for the \samp{\%()s} string interpolation. Note that
14901
291abebea55b Update the documentation for ConfigParser to match the recent changes.
Fred Drake <fdrake@acm.org>
parents: 13625
diff changeset
63 \var{__name__} is an intrinsic default; its value is the section name,
291abebea55b Update the documentation for ConfigParser to match the recent changes.
Fred Drake <fdrake@acm.org>
parents: 13625
diff changeset
64 and will override any value provided in \var{defaults}.
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
65 \end{classdesc}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
66
25918
9901fda7c366 Implement a safer and more predictable interpolation approach.
Fred Drake <fdrake@acm.org>
parents: 25913
diff changeset
67 \begin{classdesc}{SafeConfigParser}{\optional{defaults}}
9901fda7c366 Implement a safer and more predictable interpolation approach.
Fred Drake <fdrake@acm.org>
parents: 25913
diff changeset
68 Derived class of \class{ConfigParser} that implements a more-sane
9901fda7c366 Implement a safer and more predictable interpolation approach.
Fred Drake <fdrake@acm.org>
parents: 25913
diff changeset
69 variant of the magical interpolation feature. This implementation is
9901fda7c366 Implement a safer and more predictable interpolation approach.
Fred Drake <fdrake@acm.org>
parents: 25913
diff changeset
70 more predictable as well.
9901fda7c366 Implement a safer and more predictable interpolation approach.
Fred Drake <fdrake@acm.org>
parents: 25913
diff changeset
71 % XXX Need to explain what's safer/more predictable about it.
9901fda7c366 Implement a safer and more predictable interpolation approach.
Fred Drake <fdrake@acm.org>
parents: 25913
diff changeset
72 New applications should prefer this version if they don't need to be
9901fda7c366 Implement a safer and more predictable interpolation approach.
Fred Drake <fdrake@acm.org>
parents: 25913
diff changeset
73 compatible with older versions of Python.
9901fda7c366 Implement a safer and more predictable interpolation approach.
Fred Drake <fdrake@acm.org>
parents: 25913
diff changeset
74 \versionadded{2.3}
9901fda7c366 Implement a safer and more predictable interpolation approach.
Fred Drake <fdrake@acm.org>
parents: 25913
diff changeset
75 \end{classdesc}
9901fda7c366 Implement a safer and more predictable interpolation approach.
Fred Drake <fdrake@acm.org>
parents: 25913
diff changeset
76
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
77 \begin{excdesc}{NoSectionError}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
78 Exception raised when a specified section is not found.
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
79 \end{excdesc}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
80
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
81 \begin{excdesc}{DuplicateSectionError}
13625
fdfd1049f36e Rob W. W. Hooft's spelling fixes for the Library Reference. I hope
Thomas Wouters <thomas@python.org>
parents: 13602
diff changeset
82 Exception raised when multiple sections with the same name are found,
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
83 or if \method{add_section()} is called with the name of a section that
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
84 is already present.
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
85 \end{excdesc}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
86
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
87 \begin{excdesc}{NoOptionError}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
88 Exception raised when a specified option is not found in the specified
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
89 section.
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
90 \end{excdesc}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
91
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
92 \begin{excdesc}{InterpolationError}
26969
776f270a6ea9 Further cleanup of exceptions. All interpolation-related exceptions
Fred Drake <fdrake@acm.org>
parents: 26940
diff changeset
93 Base class for exceptions raised when problems occur performing string
776f270a6ea9 Further cleanup of exceptions. All interpolation-related exceptions
Fred Drake <fdrake@acm.org>
parents: 26940
diff changeset
94 interpolation.
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
95 \end{excdesc}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
96
14901
291abebea55b Update the documentation for ConfigParser to match the recent changes.
Fred Drake <fdrake@acm.org>
parents: 13625
diff changeset
97 \begin{excdesc}{InterpolationDepthError}
291abebea55b Update the documentation for ConfigParser to match the recent changes.
Fred Drake <fdrake@acm.org>
parents: 13625
diff changeset
98 Exception raised when string interpolation cannot be completed because
291abebea55b Update the documentation for ConfigParser to match the recent changes.
Fred Drake <fdrake@acm.org>
parents: 13625
diff changeset
99 the number of iterations exceeds \constant{MAX_INTERPOLATION_DEPTH}.
26969
776f270a6ea9 Further cleanup of exceptions. All interpolation-related exceptions
Fred Drake <fdrake@acm.org>
parents: 26940
diff changeset
100 Subclass of \exception{InterpolationError}.
776f270a6ea9 Further cleanup of exceptions. All interpolation-related exceptions
Fred Drake <fdrake@acm.org>
parents: 26940
diff changeset
101 \end{excdesc}
776f270a6ea9 Further cleanup of exceptions. All interpolation-related exceptions
Fred Drake <fdrake@acm.org>
parents: 26940
diff changeset
102
776f270a6ea9 Further cleanup of exceptions. All interpolation-related exceptions
Fred Drake <fdrake@acm.org>
parents: 26940
diff changeset
103 \begin{excdesc}{InterpolationMissingOptionError}
776f270a6ea9 Further cleanup of exceptions. All interpolation-related exceptions
Fred Drake <fdrake@acm.org>
parents: 26940
diff changeset
104 Exception raised when an option referenced from a value does not exist.
776f270a6ea9 Further cleanup of exceptions. All interpolation-related exceptions
Fred Drake <fdrake@acm.org>
parents: 26940
diff changeset
105 Subclass of \exception{InterpolationError}.
776f270a6ea9 Further cleanup of exceptions. All interpolation-related exceptions
Fred Drake <fdrake@acm.org>
parents: 26940
diff changeset
106 \versionadded{2.3}
14901
291abebea55b Update the documentation for ConfigParser to match the recent changes.
Fred Drake <fdrake@acm.org>
parents: 13625
diff changeset
107 \end{excdesc}
291abebea55b Update the documentation for ConfigParser to match the recent changes.
Fred Drake <fdrake@acm.org>
parents: 13625
diff changeset
108
26908
bcaca36a583c - re-mark ESR's warning about extended registry syntax
Fred Drake <fdrake@acm.org>
parents: 26812
diff changeset
109 \begin{excdesc}{InterpolationSyntaxError}
bcaca36a583c - re-mark ESR's warning about extended registry syntax
Fred Drake <fdrake@acm.org>
parents: 26812
diff changeset
110 Exception raised when the source text into which substitutions are
bcaca36a583c - re-mark ESR's warning about extended registry syntax
Fred Drake <fdrake@acm.org>
parents: 26812
diff changeset
111 made does not conform to the required syntax.
26969
776f270a6ea9 Further cleanup of exceptions. All interpolation-related exceptions
Fred Drake <fdrake@acm.org>
parents: 26940
diff changeset
112 Subclass of \exception{InterpolationError}.
26940
6e541a72af1a InterpolationSyntaxError was added in 2.3
Neal Norwitz <nnorwitz@gmail.com>
parents: 26908
diff changeset
113 \versionadded{2.3}
26908
bcaca36a583c - re-mark ESR's warning about extended registry syntax
Fred Drake <fdrake@acm.org>
parents: 26812
diff changeset
114 \end{excdesc}
bcaca36a583c - re-mark ESR's warning about extended registry syntax
Fred Drake <fdrake@acm.org>
parents: 26812
diff changeset
115
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
116 \begin{excdesc}{MissingSectionHeaderError}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
117 Exception raised when attempting to parse a file which has no section
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
118 headers.
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
119 \end{excdesc}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
120
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
121 \begin{excdesc}{ParsingError}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
122 Exception raised when errors occur attempting to parse a file.
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
123 \end{excdesc}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
124
14901
291abebea55b Update the documentation for ConfigParser to match the recent changes.
Fred Drake <fdrake@acm.org>
parents: 13625
diff changeset
125 \begin{datadesc}{MAX_INTERPOLATION_DEPTH}
291abebea55b Update the documentation for ConfigParser to match the recent changes.
Fred Drake <fdrake@acm.org>
parents: 13625
diff changeset
126 The maximum depth for recursive interpolation for \method{get()} when
25913
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
127 the \var{raw} parameter is false. This is relevant only for the
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
128 \class{ConfigParser} class.
14901
291abebea55b Update the documentation for ConfigParser to match the recent changes.
Fred Drake <fdrake@acm.org>
parents: 13625
diff changeset
129 \end{datadesc}
291abebea55b Update the documentation for ConfigParser to match the recent changes.
Fred Drake <fdrake@acm.org>
parents: 13625
diff changeset
130
9960
92a25d51ff26 Incorporate changes for patched version of ConfigParser.
Fred Drake <fdrake@acm.org>
parents: 9957
diff changeset
131
10844
cdf7ae5b3367 Added module references; minor grammatical fixes.
Fred Drake <fdrake@acm.org>
parents: 10648
diff changeset
132 \begin{seealso}
cdf7ae5b3367 Added module references; minor grammatical fixes.
Fred Drake <fdrake@acm.org>
parents: 10648
diff changeset
133 \seemodule{shlex}{Support for a creating \UNIX{} shell-like
26969
776f270a6ea9 Further cleanup of exceptions. All interpolation-related exceptions
Fred Drake <fdrake@acm.org>
parents: 26940
diff changeset
134 mini-languages which can be used as an alternate
776f270a6ea9 Further cleanup of exceptions. All interpolation-related exceptions
Fred Drake <fdrake@acm.org>
parents: 26940
diff changeset
135 format for application configuration files.}
10844
cdf7ae5b3367 Added module references; minor grammatical fixes.
Fred Drake <fdrake@acm.org>
parents: 10648
diff changeset
136 \end{seealso}
cdf7ae5b3367 Added module references; minor grammatical fixes.
Fred Drake <fdrake@acm.org>
parents: 10648
diff changeset
137
16698
1b400c854a2c ConfigParser.optionxform(): Document this since it is available for
Fred Drake <fdrake@acm.org>
parents: 15491
diff changeset
138
25913
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
139 \subsection{RawConfigParser Objects \label{RawConfigParser-objects}}
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
140
25913
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
141 \class{RawConfigParser} instances have the following methods:
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
142
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
143 \begin{methoddesc}{defaults}{}
12731
4118f002e737 From Greg Ward <gward@python.net>:
Fred Drake <fdrake@acm.org>
parents: 12636
diff changeset
144 Return a dictionary containing the instance-wide defaults.
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
145 \end{methoddesc}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
146
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
147 \begin{methoddesc}{sections}{}
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
148 Return a list of the sections available; \code{DEFAULT} is not
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
149 included in the list.
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
150 \end{methoddesc}
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
151
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
152 \begin{methoddesc}{add_section}{section}
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
153 Add a section named \var{section} to the instance. If a section by
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
154 the given name already exists, \exception{DuplicateSectionError} is
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 10988
diff changeset
155 raised.
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
156 \end{methoddesc}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
157
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
158 \begin{methoddesc}{has_section}{section}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
159 Indicates whether the named section is present in the
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
160 configuration. The \code{DEFAULT} section is not acknowledged.
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
161 \end{methoddesc}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
162
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
163 \begin{methoddesc}{options}{section}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
164 Returns a list of options available in the specified \var{section}.
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
165 \end{methoddesc}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
166
13521
4dbc75c189bc Give ConfigParser the capability to set as well as read options, and to write
Eric S. Raymond <esr@thyrsus.com>
parents: 12731
diff changeset
167 \begin{methoddesc}{has_option}{section, option}
4dbc75c189bc Give ConfigParser the capability to set as well as read options, and to write
Eric S. Raymond <esr@thyrsus.com>
parents: 12731
diff changeset
168 If the given section exists, and contains the given option. return 1;
20147
88da38a5f0bf Use consistent version annotations instead of something ad hoc.
Fred Drake <fdrake@acm.org>
parents: 16698
diff changeset
169 otherwise return 0.
88da38a5f0bf Use consistent version annotations instead of something ad hoc.
Fred Drake <fdrake@acm.org>
parents: 16698
diff changeset
170 \versionadded{1.6}
13521
4dbc75c189bc Give ConfigParser the capability to set as well as read options, and to write
Eric S. Raymond <esr@thyrsus.com>
parents: 12731
diff changeset
171 \end{methoddesc}
4dbc75c189bc Give ConfigParser the capability to set as well as read options, and to write
Eric S. Raymond <esr@thyrsus.com>
parents: 12731
diff changeset
172
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
173 \begin{methoddesc}{read}{filenames}
12636
75da9d63531d read() method: clarify that strings are accepted and interpreted
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
174 Read and parse a list of filenames. If \var{filenames} is a string or
75da9d63531d read() method: clarify that strings are accepted and interpreted
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
175 Unicode string, it is treated as a single filename.
21298
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
176 If a file named in \var{filenames} cannot be opened, that file will be
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
177 ignored. This is designed so that you can specify a list of potential
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
178 configuration file locations (for example, the current directory, the
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
179 user's home directory, and some system-wide directory), and all
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
180 existing configuration files in the list will be read. If none of the
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
181 named files exist, the \class{ConfigParser} instance will contain an
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
182 empty dataset. An application which requires initial values to be
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
183 loaded from a file should load the required file or files using
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
184 \method{readfp()} before calling \method{read()} for any optional
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
185 files:
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
186
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
187 \begin{verbatim}
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
188 import ConfigParser, os
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
189
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
190 config = ConfigParser.ConfigParser()
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
191 config.readfp(open('defaults.cfg'))
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
192 config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')])
9a243ee354a1 Describe the behavior of the read() method when the list of filenames
Fred Drake <fdrake@acm.org>
parents: 20331
diff changeset
193 \end{verbatim}
12636
75da9d63531d read() method: clarify that strings are accepted and interpreted
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
194 \end{methoddesc}
75da9d63531d read() method: clarify that strings are accepted and interpreted
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
195
75da9d63531d read() method: clarify that strings are accepted and interpreted
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
196 \begin{methoddesc}{readfp}{fp\optional{, filename}}
75da9d63531d read() method: clarify that strings are accepted and interpreted
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
197 Read and parse configuration data from the file or file-like object in
75da9d63531d read() method: clarify that strings are accepted and interpreted
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
198 \var{fp} (only the \method{readline()} method is used). If
75da9d63531d read() method: clarify that strings are accepted and interpreted
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
199 \var{filename} is omitted and \var{fp} has a \member{name} attribute,
75da9d63531d read() method: clarify that strings are accepted and interpreted
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
200 that is used for \var{filename}; the default is \samp{<???>}.
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
201 \end{methoddesc}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
202
25913
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
203 \begin{methoddesc}{get}{section, option}
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
204 Get an \var{option} value for the named \var{section}.
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
205 \end{methoddesc}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
206
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
207 \begin{methoddesc}{getint}{section, option}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
208 A convenience method which coerces the \var{option} in the specified
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
209 \var{section} to an integer.
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
210 \end{methoddesc}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
211
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
212 \begin{methoddesc}{getfloat}{section, option}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
213 A convenience method which coerces the \var{option} in the specified
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
214 \var{section} to a floating point number.
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
215 \end{methoddesc}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
216
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
217 \begin{methoddesc}{getboolean}{section, option}
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
218 A convenience method which coerces the \var{option} in the specified
20318
f9a66b24bfff Update the description of getboolean() to reflect the changes made by
Fred Drake <fdrake@acm.org>
parents: 20202
diff changeset
219 \var{section} to a Boolean value. Note that the accepted values
f9a66b24bfff Update the description of getboolean() to reflect the changes made by
Fred Drake <fdrake@acm.org>
parents: 20202
diff changeset
220 for the option are \code{1}, \code{yes}, \code{true}, and \code{on},
f9a66b24bfff Update the description of getboolean() to reflect the changes made by
Fred Drake <fdrake@acm.org>
parents: 20202
diff changeset
221 which cause this method to return true, and \code{0}, \code{no},
20331
c5247a366ff5 Note that the values for Boolean options are case-insensitive.
Fred Drake <fdrake@acm.org>
parents: 20318
diff changeset
222 \code{false}, and \code{off}, which cause it to return false. These
c5247a366ff5 Note that the values for Boolean options are case-insensitive.
Fred Drake <fdrake@acm.org>
parents: 20318
diff changeset
223 values are checked in a case-insensitive manner. Any other value will
c5247a366ff5 Note that the values for Boolean options are case-insensitive.
Fred Drake <fdrake@acm.org>
parents: 20318
diff changeset
224 cause it to raise \exception{ValueError}.
9957
57bcc6ec638f Documentation for the ConfigParser module, by Christopher G. Petrilli
Fred Drake <fdrake@acm.org>
parents:
diff changeset
225 \end{methoddesc}
13521
4dbc75c189bc Give ConfigParser the capability to set as well as read options, and to write
Eric S. Raymond <esr@thyrsus.com>
parents: 12731
diff changeset
226
25913
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
227 \begin{methoddesc}{items}{section}
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
228 Return a list of \code{(\var{name}, \var{value})} pairs for each
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
229 option in the given \var{section}.
25461
09551c6da299 items(): New method, provided by Gustavo Niemeyer in SF bug #545096.
Fred Drake <fdrake@acm.org>
parents: 22835
diff changeset
230 \end{methoddesc}
09551c6da299 items(): New method, provided by Gustavo Niemeyer in SF bug #545096.
Fred Drake <fdrake@acm.org>
parents: 22835
diff changeset
231
13521
4dbc75c189bc Give ConfigParser the capability to set as well as read options, and to write
Eric S. Raymond <esr@thyrsus.com>
parents: 12731
diff changeset
232 \begin{methoddesc}{set}{section, option, value}
4dbc75c189bc Give ConfigParser the capability to set as well as read options, and to write
Eric S. Raymond <esr@thyrsus.com>
parents: 12731
diff changeset
233 If the given section exists, set the given option to the specified value;
20147
88da38a5f0bf Use consistent version annotations instead of something ad hoc.
Fred Drake <fdrake@acm.org>
parents: 16698
diff changeset
234 otherwise raise \exception{NoSectionError}.
88da38a5f0bf Use consistent version annotations instead of something ad hoc.
Fred Drake <fdrake@acm.org>
parents: 16698
diff changeset
235 \versionadded{1.6}
13521
4dbc75c189bc Give ConfigParser the capability to set as well as read options, and to write
Eric S. Raymond <esr@thyrsus.com>
parents: 12731
diff changeset
236 \end{methoddesc}
4dbc75c189bc Give ConfigParser the capability to set as well as read options, and to write
Eric S. Raymond <esr@thyrsus.com>
parents: 12731
diff changeset
237
13602
d7aec17cd0b5 Document the second round of ConfigParser changes.
Eric S. Raymond <esr@thyrsus.com>
parents: 13521
diff changeset
238 \begin{methoddesc}{write}{fileobject}
13521
4dbc75c189bc Give ConfigParser the capability to set as well as read options, and to write
Eric S. Raymond <esr@thyrsus.com>
parents: 12731
diff changeset
239 Write a representation of the configuration to the specified file
4dbc75c189bc Give ConfigParser the capability to set as well as read options, and to write
Eric S. Raymond <esr@thyrsus.com>
parents: 12731
diff changeset
240 object. This representation can be parsed by a future \method{read()}
20147
88da38a5f0bf Use consistent version annotations instead of something ad hoc.
Fred Drake <fdrake@acm.org>
parents: 16698
diff changeset
241 call.
88da38a5f0bf Use consistent version annotations instead of something ad hoc.
Fred Drake <fdrake@acm.org>
parents: 16698
diff changeset
242 \versionadded{1.6}
13521
4dbc75c189bc Give ConfigParser the capability to set as well as read options, and to write
Eric S. Raymond <esr@thyrsus.com>
parents: 12731
diff changeset
243 \end{methoddesc}
13602
d7aec17cd0b5 Document the second round of ConfigParser changes.
Eric S. Raymond <esr@thyrsus.com>
parents: 13521
diff changeset
244
d7aec17cd0b5 Document the second round of ConfigParser changes.
Eric S. Raymond <esr@thyrsus.com>
parents: 13521
diff changeset
245 \begin{methoddesc}{remove_option}{section, option}
d7aec17cd0b5 Document the second round of ConfigParser changes.
Eric S. Raymond <esr@thyrsus.com>
parents: 13521
diff changeset
246 Remove the specified \var{option} from the specified \var{section}.
d7aec17cd0b5 Document the second round of ConfigParser changes.
Eric S. Raymond <esr@thyrsus.com>
parents: 13521
diff changeset
247 If the section does not exist, raise \exception{NoSectionError}.
d7aec17cd0b5 Document the second round of ConfigParser changes.
Eric S. Raymond <esr@thyrsus.com>
parents: 13521
diff changeset
248 If the option existed to be removed, return 1; otherwise return 0.
20147
88da38a5f0bf Use consistent version annotations instead of something ad hoc.
Fred Drake <fdrake@acm.org>
parents: 16698
diff changeset
249 \versionadded{1.6}
13602
d7aec17cd0b5 Document the second round of ConfigParser changes.
Eric S. Raymond <esr@thyrsus.com>
parents: 13521
diff changeset
250 \end{methoddesc}
d7aec17cd0b5 Document the second round of ConfigParser changes.
Eric S. Raymond <esr@thyrsus.com>
parents: 13521
diff changeset
251
d7aec17cd0b5 Document the second round of ConfigParser changes.
Eric S. Raymond <esr@thyrsus.com>
parents: 13521
diff changeset
252 \begin{methoddesc}{remove_section}{section}
d7aec17cd0b5 Document the second round of ConfigParser changes.
Eric S. Raymond <esr@thyrsus.com>
parents: 13521
diff changeset
253 Remove the specified \var{section} from the configuration.
22835
73d145bfd8e4 Update doc to reflect Tim's changes to bool.
Neal Norwitz <nnorwitz@gmail.com>
parents: 21298
diff changeset
254 If the section in fact existed, return \code{True}.
73d145bfd8e4 Update doc to reflect Tim's changes to bool.
Neal Norwitz <nnorwitz@gmail.com>
parents: 21298
diff changeset
255 Otherwise return \code{False}.
13602
d7aec17cd0b5 Document the second round of ConfigParser changes.
Eric S. Raymond <esr@thyrsus.com>
parents: 13521
diff changeset
256 \end{methoddesc}
d7aec17cd0b5 Document the second round of ConfigParser changes.
Eric S. Raymond <esr@thyrsus.com>
parents: 13521
diff changeset
257
16698
1b400c854a2c ConfigParser.optionxform(): Document this since it is available for
Fred Drake <fdrake@acm.org>
parents: 15491
diff changeset
258 \begin{methoddesc}{optionxform}{option}
1b400c854a2c ConfigParser.optionxform(): Document this since it is available for
Fred Drake <fdrake@acm.org>
parents: 15491
diff changeset
259 Transforms the option name \var{option} as found in an input file or
1b400c854a2c ConfigParser.optionxform(): Document this since it is available for
Fred Drake <fdrake@acm.org>
parents: 15491
diff changeset
260 as passed in by client code to the form that should be used in the
1b400c854a2c ConfigParser.optionxform(): Document this since it is available for
Fred Drake <fdrake@acm.org>
parents: 15491
diff changeset
261 internal structures. The default implementation returns a lower-case
1b400c854a2c ConfigParser.optionxform(): Document this since it is available for
Fred Drake <fdrake@acm.org>
parents: 15491
diff changeset
262 version of \var{option}; subclasses may override this or client code
1b400c854a2c ConfigParser.optionxform(): Document this since it is available for
Fred Drake <fdrake@acm.org>
parents: 15491
diff changeset
263 can set an attribute of this name on instances to affect this
1b400c854a2c ConfigParser.optionxform(): Document this since it is available for
Fred Drake <fdrake@acm.org>
parents: 15491
diff changeset
264 behavior. Setting this to \function{str()}, for example, would make
1b400c854a2c ConfigParser.optionxform(): Document this since it is available for
Fred Drake <fdrake@acm.org>
parents: 15491
diff changeset
265 option names case sensitive.
1b400c854a2c ConfigParser.optionxform(): Document this since it is available for
Fred Drake <fdrake@acm.org>
parents: 15491
diff changeset
266 \end{methoddesc}
25913
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
267
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
268
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
269 \subsection{ConfigParser Objects \label{ConfigParser-objects}}
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
270
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
271 The \class{ConfigParser} class extends some methods of the
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
272 \class{RawConfigParser} interface, adding some optional arguments.
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
273
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
274 \begin{methoddesc}{get}{section, option\optional{, raw\optional{, vars}}}
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
275 Get an \var{option} value for the named \var{section}. All the
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
276 \character{\%} interpolations are expanded in the return values, based
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
277 on the defaults passed into the constructor, as well as the options
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
278 \var{vars} provided, unless the \var{raw} argument is true.
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
279 \end{methoddesc}
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
280
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
281 \begin{methoddesc}{items}{section\optional{, raw\optional{, vars}}}
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
282 Create a generator which will return a tuple \code{(name, value)} for
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
283 each option in the given \var{section}. Optional arguments have the
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
284 same meaning as for the \code{get()} method.
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
285 \versionadded{2.3}
fba16b9bc951 Update to reflect the refactoring into the RawConfigParser and
Fred Drake <fdrake@acm.org>
parents: 25461
diff changeset
286 \end{methoddesc}