Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / html / python / lib / RawConfigParser-objects.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="ConfigParser-objects.html" />
<link rel="prev" href="module-ConfigParser.html" />
<link rel="parent" href="module-ConfigParser.html" />
<link rel="next" href="ConfigParser-objects.html" />
<meta name='aesop' content='information' />
<title>5.17.1 RawConfigParser Objects </title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="5.17 ConfigParser "
href="module-ConfigParser.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="5.17 ConfigParser "
href="module-ConfigParser.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="5.17.2 ConfigParser Objects"
href="ConfigParser-objects.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-ConfigParser.html">5.17 ConfigParser </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-ConfigParser.html">5.17 ConfigParser </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="ConfigParser-objects.html">5.17.2 ConfigParser Objects</A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION0071710000000000000000"></A><A NAME="RawConfigParser-objects"></A>
<BR>
5.17.1 RawConfigParser Objects
</H2>
<P>
<tt class="class">RawConfigParser</tt> instances have the following methods:
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1414' xml:id='l2h-1414' class="method">defaults</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return a dictionary containing the instance-wide defaults.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1415' xml:id='l2h-1415' class="method">sections</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return a list of the sections available; <code>DEFAULT</code> is not
included in the list.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1416' xml:id='l2h-1416' class="method">add_section</tt></b>(</nobr></td>
<td><var>section</var>)</td></tr></table></dt>
<dd>
Add a section named <var>section</var> to the instance. If a section by
the given name already exists, <tt class="exception">DuplicateSectionError</tt> is
raised.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1417' xml:id='l2h-1417' class="method">has_section</tt></b>(</nobr></td>
<td><var>section</var>)</td></tr></table></dt>
<dd>
Indicates whether the named section is present in the
configuration. The <code>DEFAULT</code> section is not acknowledged.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1418' xml:id='l2h-1418' class="method">options</tt></b>(</nobr></td>
<td><var>section</var>)</td></tr></table></dt>
<dd>
Returns a list of options available in the specified <var>section</var>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1419' xml:id='l2h-1419' class="method">has_option</tt></b>(</nobr></td>
<td><var>section, option</var>)</td></tr></table></dt>
<dd>
If the given section exists, and contains the given option,
return <tt class="constant">True</tt>; otherwise return <tt class="constant">False</tt>.
<span class="versionnote">New in version 1.6.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1420' xml:id='l2h-1420' class="method">read</tt></b>(</nobr></td>
<td><var>filenames</var>)</td></tr></table></dt>
<dd>
Attempt to read and parse a list of filenames, returning a list of filenames
which were successfully parsed. If <var>filenames</var> is a string or
Unicode string, it is treated as a single filename.
If a file named in <var>filenames</var> cannot be opened, that file will be
ignored. This is designed so that you can specify a list of potential
configuration file locations (for example, the current directory, the
user's home directory, and some system-wide directory), and all
existing configuration files in the list will be read. If none of the
named files exist, the <tt class="class">ConfigParser</tt> instance will contain an
empty dataset. An application which requires initial values to be
loaded from a file should load the required file or files using
<tt class="method">readfp()</tt> before calling <tt class="method">read()</tt> for any optional
files:
<P>
<div class="verbatim"><pre>
import ConfigParser, os
config = ConfigParser.ConfigParser()
config.readfp(open('defaults.cfg'))
config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')])
</pre></div>
<span class="versionnote">Changed in version 2.4:
Returns list of successfully parsed filenames.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1421' xml:id='l2h-1421' class="method">readfp</tt></b>(</nobr></td>
<td><var>fp</var><big>[</big><var>, filename</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Read and parse configuration data from the file or file-like object in
<var>fp</var> (only the <tt class="method">readline()</tt> method is used). If
<var>filename</var> is omitted and <var>fp</var> has a <tt class="member">name</tt> attribute,
that is used for <var>filename</var>; the default is "<tt class="samp">&lt;???&gt;</tt>".
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1422' xml:id='l2h-1422' class="method">get</tt></b>(</nobr></td>
<td><var>section, option</var>)</td></tr></table></dt>
<dd>
Get an <var>option</var> value for the named <var>section</var>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1423' xml:id='l2h-1423' class="method">getint</tt></b>(</nobr></td>
<td><var>section, option</var>)</td></tr></table></dt>
<dd>
A convenience method which coerces the <var>option</var> in the specified
<var>section</var> to an integer.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1424' xml:id='l2h-1424' class="method">getfloat</tt></b>(</nobr></td>
<td><var>section, option</var>)</td></tr></table></dt>
<dd>
A convenience method which coerces the <var>option</var> in the specified
<var>section</var> to a floating point number.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1425' xml:id='l2h-1425' class="method">getboolean</tt></b>(</nobr></td>
<td><var>section, option</var>)</td></tr></table></dt>
<dd>
A convenience method which coerces the <var>option</var> in the specified
<var>section</var> to a Boolean value. Note that the accepted values
for the option are <code>"1"</code>, <code>"yes"</code>, <code>"true"</code>, and <code>"on"</code>,
which cause this method to return <code>True</code>, and <code>"0"</code>, <code>"no"</code>,
<code>"false"</code>, and <code>"off"</code>, which cause it to return <code>False</code>. These
string values are checked in a case-insensitive manner. Any other value will
cause it to raise <tt class="exception">ValueError</tt>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1426' xml:id='l2h-1426' class="method">items</tt></b>(</nobr></td>
<td><var>section</var>)</td></tr></table></dt>
<dd>
Return a list of <code>(<var>name</var>, <var>value</var>)</code> pairs for each
option in the given <var>section</var>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1427' xml:id='l2h-1427' class="method">set</tt></b>(</nobr></td>
<td><var>section, option, value</var>)</td></tr></table></dt>
<dd>
If the given section exists, set the given option to the specified
value; otherwise raise <tt class="exception">NoSectionError</tt>. While it is
possible to use <tt class="class">RawConfigParser</tt> (or <tt class="class">ConfigParser</tt> with
<var>raw</var> parameters set to true) for <em>internal</em> storage of
non-string values, full functionality (including interpolation and
output to files) can only be achieved using string values.
<span class="versionnote">New in version 1.6.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1428' xml:id='l2h-1428' class="method">write</tt></b>(</nobr></td>
<td><var>fileobject</var>)</td></tr></table></dt>
<dd>
Write a representation of the configuration to the specified file
object. This representation can be parsed by a future <tt class="method">read()</tt>
call.
<span class="versionnote">New in version 1.6.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1429' xml:id='l2h-1429' class="method">remove_option</tt></b>(</nobr></td>
<td><var>section, option</var>)</td></tr></table></dt>
<dd>
Remove the specified <var>option</var> from the specified <var>section</var>.
If the section does not exist, raise <tt class="exception">NoSectionError</tt>.
If the option existed to be removed, return <tt class="constant">True</tt>;
otherwise return <tt class="constant">False</tt>.
<span class="versionnote">New in version 1.6.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1430' xml:id='l2h-1430' class="method">remove_section</tt></b>(</nobr></td>
<td><var>section</var>)</td></tr></table></dt>
<dd>
Remove the specified <var>section</var> from the configuration.
If the section in fact existed, return <code>True</code>.
Otherwise return <code>False</code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1431' xml:id='l2h-1431' class="method">optionxform</tt></b>(</nobr></td>
<td><var>option</var>)</td></tr></table></dt>
<dd>
Transforms the option name <var>option</var> as found in an input file or
as passed in by client code to the form that should be used in the
internal structures. The default implementation returns a lower-case
version of <var>option</var>; subclasses may override this or client code
can set an attribute of this name on instances to affect this
behavior. Setting this to <tt class="function">str()</tt>, for example, would make
option names case sensitive.
</dl>
<P>
<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="5.17 ConfigParser "
href="module-ConfigParser.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="5.17 ConfigParser "
href="module-ConfigParser.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="5.17.2 ConfigParser Objects"
href="ConfigParser-objects.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-ConfigParser.html">5.17 ConfigParser </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-ConfigParser.html">5.17 ConfigParser </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="ConfigParser-objects.html">5.17.2 ConfigParser Objects</A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>