Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / html / python / lib / RawConfigParser-objects.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="ConfigParser-objects.html" />
13<link rel="prev" href="module-ConfigParser.html" />
14<link rel="parent" href="module-ConfigParser.html" />
15<link rel="next" href="ConfigParser-objects.html" />
16<meta name='aesop' content='information' />
17<title>5.17.1 RawConfigParser Objects </title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="5.17 ConfigParser "
25 href="module-ConfigParser.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="5.17 ConfigParser "
28 href="module-ConfigParser.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="5.17.2 ConfigParser Objects"
31 href="ConfigParser-objects.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="module-ConfigParser.html">5.17 ConfigParser </A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="module-ConfigParser.html">5.17 ConfigParser </A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="ConfigParser-objects.html">5.17.2 ConfigParser Objects</A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H2><A NAME="SECTION0071710000000000000000"></A><A NAME="RawConfigParser-objects"></A>
56<BR>
575.17.1 RawConfigParser Objects
58</H2>
59
60<P>
61<tt class="class">RawConfigParser</tt> instances have the following methods:
62
63<P>
64<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
65 <td><nobr><b><tt id='l2h-1414' xml:id='l2h-1414' class="method">defaults</tt></b>(</nobr></td>
66 <td><var></var>)</td></tr></table></dt>
67<dd>
68Return a dictionary containing the instance-wide defaults.
69</dl>
70
71<P>
72<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
73 <td><nobr><b><tt id='l2h-1415' xml:id='l2h-1415' class="method">sections</tt></b>(</nobr></td>
74 <td><var></var>)</td></tr></table></dt>
75<dd>
76Return a list of the sections available; <code>DEFAULT</code> is not
77included in the list.
78</dl>
79
80<P>
81<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
82 <td><nobr><b><tt id='l2h-1416' xml:id='l2h-1416' class="method">add_section</tt></b>(</nobr></td>
83 <td><var>section</var>)</td></tr></table></dt>
84<dd>
85Add a section named <var>section</var> to the instance. If a section by
86the given name already exists, <tt class="exception">DuplicateSectionError</tt> is
87raised.
88</dl>
89
90<P>
91<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
92 <td><nobr><b><tt id='l2h-1417' xml:id='l2h-1417' class="method">has_section</tt></b>(</nobr></td>
93 <td><var>section</var>)</td></tr></table></dt>
94<dd>
95Indicates whether the named section is present in the
96configuration. The <code>DEFAULT</code> section is not acknowledged.
97</dl>
98
99<P>
100<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
101 <td><nobr><b><tt id='l2h-1418' xml:id='l2h-1418' class="method">options</tt></b>(</nobr></td>
102 <td><var>section</var>)</td></tr></table></dt>
103<dd>
104Returns a list of options available in the specified <var>section</var>.
105</dl>
106
107<P>
108<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
109 <td><nobr><b><tt id='l2h-1419' xml:id='l2h-1419' class="method">has_option</tt></b>(</nobr></td>
110 <td><var>section, option</var>)</td></tr></table></dt>
111<dd>
112If the given section exists, and contains the given option,
113return <tt class="constant">True</tt>; otherwise return <tt class="constant">False</tt>.
114
115<span class="versionnote">New in version 1.6.</span>
116
117</dl>
118
119<P>
120<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
121 <td><nobr><b><tt id='l2h-1420' xml:id='l2h-1420' class="method">read</tt></b>(</nobr></td>
122 <td><var>filenames</var>)</td></tr></table></dt>
123<dd>
124Attempt to read and parse a list of filenames, returning a list of filenames
125which were successfully parsed. If <var>filenames</var> is a string or
126Unicode string, it is treated as a single filename.
127If a file named in <var>filenames</var> cannot be opened, that file will be
128ignored. This is designed so that you can specify a list of potential
129configuration file locations (for example, the current directory, the
130user's home directory, and some system-wide directory), and all
131existing configuration files in the list will be read. If none of the
132named files exist, the <tt class="class">ConfigParser</tt> instance will contain an
133empty dataset. An application which requires initial values to be
134loaded from a file should load the required file or files using
135<tt class="method">readfp()</tt> before calling <tt class="method">read()</tt> for any optional
136files:
137
138<P>
139<div class="verbatim"><pre>
140import ConfigParser, os
141
142config = ConfigParser.ConfigParser()
143config.readfp(open('defaults.cfg'))
144config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')])
145</pre></div>
146
147<span class="versionnote">Changed in version 2.4:
148Returns list of successfully parsed filenames.</span>
149
150</dl>
151
152<P>
153<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
154 <td><nobr><b><tt id='l2h-1421' xml:id='l2h-1421' class="method">readfp</tt></b>(</nobr></td>
155 <td><var>fp</var><big>[</big><var>, filename</var><big>]</big><var></var>)</td></tr></table></dt>
156<dd>
157Read and parse configuration data from the file or file-like object in
158<var>fp</var> (only the <tt class="method">readline()</tt> method is used). If
159<var>filename</var> is omitted and <var>fp</var> has a <tt class="member">name</tt> attribute,
160that is used for <var>filename</var>; the default is "<tt class="samp">&lt;???&gt;</tt>".
161</dl>
162
163<P>
164<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
165 <td><nobr><b><tt id='l2h-1422' xml:id='l2h-1422' class="method">get</tt></b>(</nobr></td>
166 <td><var>section, option</var>)</td></tr></table></dt>
167<dd>
168Get an <var>option</var> value for the named <var>section</var>.
169</dl>
170
171<P>
172<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
173 <td><nobr><b><tt id='l2h-1423' xml:id='l2h-1423' class="method">getint</tt></b>(</nobr></td>
174 <td><var>section, option</var>)</td></tr></table></dt>
175<dd>
176A convenience method which coerces the <var>option</var> in the specified
177<var>section</var> to an integer.
178</dl>
179
180<P>
181<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
182 <td><nobr><b><tt id='l2h-1424' xml:id='l2h-1424' class="method">getfloat</tt></b>(</nobr></td>
183 <td><var>section, option</var>)</td></tr></table></dt>
184<dd>
185A convenience method which coerces the <var>option</var> in the specified
186<var>section</var> to a floating point number.
187</dl>
188
189<P>
190<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
191 <td><nobr><b><tt id='l2h-1425' xml:id='l2h-1425' class="method">getboolean</tt></b>(</nobr></td>
192 <td><var>section, option</var>)</td></tr></table></dt>
193<dd>
194A convenience method which coerces the <var>option</var> in the specified
195<var>section</var> to a Boolean value. Note that the accepted values
196for the option are <code>"1"</code>, <code>"yes"</code>, <code>"true"</code>, and <code>"on"</code>,
197which cause this method to return <code>True</code>, and <code>"0"</code>, <code>"no"</code>,
198<code>"false"</code>, and <code>"off"</code>, which cause it to return <code>False</code>. These
199string values are checked in a case-insensitive manner. Any other value will
200cause it to raise <tt class="exception">ValueError</tt>.
201</dl>
202
203<P>
204<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
205 <td><nobr><b><tt id='l2h-1426' xml:id='l2h-1426' class="method">items</tt></b>(</nobr></td>
206 <td><var>section</var>)</td></tr></table></dt>
207<dd>
208Return a list of <code>(<var>name</var>, <var>value</var>)</code> pairs for each
209option in the given <var>section</var>.
210</dl>
211
212<P>
213<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
214 <td><nobr><b><tt id='l2h-1427' xml:id='l2h-1427' class="method">set</tt></b>(</nobr></td>
215 <td><var>section, option, value</var>)</td></tr></table></dt>
216<dd>
217If the given section exists, set the given option to the specified
218value; otherwise raise <tt class="exception">NoSectionError</tt>. While it is
219possible to use <tt class="class">RawConfigParser</tt> (or <tt class="class">ConfigParser</tt> with
220<var>raw</var> parameters set to true) for <em>internal</em> storage of
221non-string values, full functionality (including interpolation and
222output to files) can only be achieved using string values.
223
224<span class="versionnote">New in version 1.6.</span>
225
226</dl>
227
228<P>
229<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
230 <td><nobr><b><tt id='l2h-1428' xml:id='l2h-1428' class="method">write</tt></b>(</nobr></td>
231 <td><var>fileobject</var>)</td></tr></table></dt>
232<dd>
233Write a representation of the configuration to the specified file
234object. This representation can be parsed by a future <tt class="method">read()</tt>
235call.
236
237<span class="versionnote">New in version 1.6.</span>
238
239</dl>
240
241<P>
242<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
243 <td><nobr><b><tt id='l2h-1429' xml:id='l2h-1429' class="method">remove_option</tt></b>(</nobr></td>
244 <td><var>section, option</var>)</td></tr></table></dt>
245<dd>
246Remove the specified <var>option</var> from the specified <var>section</var>.
247If the section does not exist, raise <tt class="exception">NoSectionError</tt>.
248If the option existed to be removed, return <tt class="constant">True</tt>;
249otherwise return <tt class="constant">False</tt>.
250
251<span class="versionnote">New in version 1.6.</span>
252
253</dl>
254
255<P>
256<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
257 <td><nobr><b><tt id='l2h-1430' xml:id='l2h-1430' class="method">remove_section</tt></b>(</nobr></td>
258 <td><var>section</var>)</td></tr></table></dt>
259<dd>
260Remove the specified <var>section</var> from the configuration.
261If the section in fact existed, return <code>True</code>.
262Otherwise return <code>False</code>.
263</dl>
264
265<P>
266<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
267 <td><nobr><b><tt id='l2h-1431' xml:id='l2h-1431' class="method">optionxform</tt></b>(</nobr></td>
268 <td><var>option</var>)</td></tr></table></dt>
269<dd>
270Transforms the option name <var>option</var> as found in an input file or
271as passed in by client code to the form that should be used in the
272internal structures. The default implementation returns a lower-case
273version of <var>option</var>; subclasses may override this or client code
274can set an attribute of this name on instances to affect this
275behavior. Setting this to <tt class="function">str()</tt>, for example, would make
276option names case sensitive.
277</dl>
278
279<P>
280
281<DIV CLASS="navigation">
282<div class='online-navigation'>
283<p></p><hr />
284<table align="center" width="100%" cellpadding="0" cellspacing="2">
285<tr>
286<td class='online-navigation'><a rel="prev" title="5.17 ConfigParser "
287 href="module-ConfigParser.html"><img src='../icons/previous.png'
288 border='0' height='32' alt='Previous Page' width='32' /></A></td>
289<td class='online-navigation'><a rel="parent" title="5.17 ConfigParser "
290 href="module-ConfigParser.html"><img src='../icons/up.png'
291 border='0' height='32' alt='Up One Level' width='32' /></A></td>
292<td class='online-navigation'><a rel="next" title="5.17.2 ConfigParser Objects"
293 href="ConfigParser-objects.html"><img src='../icons/next.png'
294 border='0' height='32' alt='Next Page' width='32' /></A></td>
295<td align="center" width="100%">Python Library Reference</td>
296<td class='online-navigation'><a rel="contents" title="Table of Contents"
297 href="contents.html"><img src='../icons/contents.png'
298 border='0' height='32' alt='Contents' width='32' /></A></td>
299<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
300 border='0' height='32' alt='Module Index' width='32' /></a></td>
301<td class='online-navigation'><a rel="index" title="Index"
302 href="genindex.html"><img src='../icons/index.png'
303 border='0' height='32' alt='Index' width='32' /></A></td>
304</tr></table>
305<div class='online-navigation'>
306<b class="navlabel">Previous:</b>
307<a class="sectref" rel="prev" href="module-ConfigParser.html">5.17 ConfigParser </A>
308<b class="navlabel">Up:</b>
309<a class="sectref" rel="parent" href="module-ConfigParser.html">5.17 ConfigParser </A>
310<b class="navlabel">Next:</b>
311<a class="sectref" rel="next" href="ConfigParser-objects.html">5.17.2 ConfigParser Objects</A>
312</div>
313</div>
314<hr />
315<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
316</DIV>
317<!--End of Navigation Panel-->
318<ADDRESS>
319See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
320</ADDRESS>
321</BODY>
322</HTML>