Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / html / python / lib / MultiFile-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="multifile-example.html" />
13<link rel="prev" href="module-multifile.html" />
14<link rel="parent" href="module-multifile.html" />
15<link rel="next" href="multifile-example.html" />
16<meta name='aesop' content='information' />
17<title>12.10.1 MultiFile 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="12.10 multifile "
25 href="module-multifile.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="12.10 multifile "
28 href="module-multifile.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="12.10.2 MultiFile Example"
31 href="multifile-example.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-multifile.html">12.10 multifile </A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="module-multifile.html">12.10 multifile </A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="multifile-example.html">12.10.2 MultiFile Example</A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H2><A NAME="SECTION00141010000000000000000"></A><A NAME="MultiFile-objects"></A>
56<BR>
5712.10.1 MultiFile Objects
58</H2>
59
60<P>
61A <tt class="class">MultiFile</tt> instance has the following methods:
62
63<P>
64<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
65 <td><nobr><b><tt id='l2h-4060' xml:id='l2h-4060' class="method">readline</tt></b>(</nobr></td>
66 <td><var>str</var>)</td></tr></table></dt>
67<dd>
68Read a line. If the line is data (not a section-divider or end-marker
69or real EOF) return it. If the line matches the most-recently-stacked
70boundary, return <code>''</code> and set <code>self.last</code> to 1 or 0 according as
71the match is or is not an end-marker. If the line matches any other
72stacked boundary, raise an error. On encountering end-of-file on the
73underlying stream object, the method raises <tt class="exception">Error</tt> unless
74all boundaries have been popped.
75</dl>
76
77<P>
78<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
79 <td><nobr><b><tt id='l2h-4061' xml:id='l2h-4061' class="method">readlines</tt></b>(</nobr></td>
80 <td><var>str</var>)</td></tr></table></dt>
81<dd>
82Return all lines remaining in this part as a list of strings.
83</dl>
84
85<P>
86<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
87 <td><nobr><b><tt id='l2h-4062' xml:id='l2h-4062' class="method">read</tt></b>(</nobr></td>
88 <td><var></var>)</td></tr></table></dt>
89<dd>
90Read all lines, up to the next section. Return them as a single
91(multiline) string. Note that this doesn't take a size argument!
92</dl>
93
94<P>
95<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
96 <td><nobr><b><tt id='l2h-4063' xml:id='l2h-4063' class="method">seek</tt></b>(</nobr></td>
97 <td><var>pos</var><big>[</big><var>, whence</var><big>]</big><var></var>)</td></tr></table></dt>
98<dd>
99Seek. Seek indices are relative to the start of the current section.
100The <var>pos</var> and <var>whence</var> arguments are interpreted as for a file
101seek.
102</dl>
103
104<P>
105<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
106 <td><nobr><b><tt id='l2h-4064' xml:id='l2h-4064' class="method">tell</tt></b>(</nobr></td>
107 <td><var></var>)</td></tr></table></dt>
108<dd>
109Return the file position relative to the start of the current section.
110</dl>
111
112<P>
113<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
114 <td><nobr><b><tt id='l2h-4065' xml:id='l2h-4065' class="method">next</tt></b>(</nobr></td>
115 <td><var></var>)</td></tr></table></dt>
116<dd>
117Skip lines to the next section (that is, read lines until a
118section-divider or end-marker has been consumed). Return true if
119there is such a section, false if an end-marker is seen. Re-enable
120the most-recently-pushed boundary.
121</dl>
122
123<P>
124<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
125 <td><nobr><b><tt id='l2h-4066' xml:id='l2h-4066' class="method">is_data</tt></b>(</nobr></td>
126 <td><var>str</var>)</td></tr></table></dt>
127<dd>
128Return true if <var>str</var> is data and false if it might be a section
129boundary. As written, it tests for a prefix other than <code>'-</code><code>-'</code> at
130start of line (which all MIME boundaries have) but it is declared so
131it can be overridden in derived classes.
132
133<P>
134Note that this test is used intended as a fast guard for the real
135boundary tests; if it always returns false it will merely slow
136processing, not cause it to fail.
137</dl>
138
139<P>
140<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
141 <td><nobr><b><tt id='l2h-4067' xml:id='l2h-4067' class="method">push</tt></b>(</nobr></td>
142 <td><var>str</var>)</td></tr></table></dt>
143<dd>
144Push a boundary string. When an appropriately decorated version of
145this boundary is found as an input line, it will be interpreted as a
146section-divider or end-marker. All subsequent
147reads will return the empty string to indicate end-of-file, until a
148call to <tt class="method">pop()</tt> removes the boundary a or <tt class="method">next()</tt> call
149reenables it.
150
151<P>
152It is possible to push more than one boundary. Encountering the
153most-recently-pushed boundary will return EOF; encountering any other
154boundary will raise an error.
155</dl>
156
157<P>
158<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
159 <td><nobr><b><tt id='l2h-4068' xml:id='l2h-4068' class="method">pop</tt></b>(</nobr></td>
160 <td><var></var>)</td></tr></table></dt>
161<dd>
162Pop a section boundary. This boundary will no longer be interpreted
163as EOF.
164</dl>
165
166<P>
167<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
168 <td><nobr><b><tt id='l2h-4069' xml:id='l2h-4069' class="method">section_divider</tt></b>(</nobr></td>
169 <td><var>str</var>)</td></tr></table></dt>
170<dd>
171Turn a boundary into a section-divider line. By default, this
172method prepends <code>'-</code><code>-'</code> (which MIME section boundaries have) but
173it is declared so it can be overridden in derived classes. This
174method need not append LF or CR-LF, as comparison with the result
175ignores trailing whitespace.
176</dl>
177
178<P>
179<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
180 <td><nobr><b><tt id='l2h-4070' xml:id='l2h-4070' class="method">end_marker</tt></b>(</nobr></td>
181 <td><var>str</var>)</td></tr></table></dt>
182<dd>
183Turn a boundary string into an end-marker line. By default, this
184method prepends <code>'-</code><code>-'</code> and appends <code>'-</code><code>-'</code> (like a
185MIME-multipart end-of-message marker) but it is declared so it can be
186overridden in derived classes. This method need not append LF or
187CR-LF, as comparison with the result ignores trailing whitespace.
188</dl>
189
190<P>
191Finally, <tt class="class">MultiFile</tt> instances have two public instance variables:
192
193<P>
194<dl><dt><b><tt id='l2h-4071' xml:id='l2h-4071' class="member">level</tt></b></dt>
195<dd>
196Nesting depth of the current part.
197</dl>
198
199<P>
200<dl><dt><b><tt id='l2h-4072' xml:id='l2h-4072' class="member">last</tt></b></dt>
201<dd>
202True if the last end-of-file was for an end-of-message marker.
203</dl>
204
205<P>
206
207<DIV CLASS="navigation">
208<div class='online-navigation'>
209<p></p><hr />
210<table align="center" width="100%" cellpadding="0" cellspacing="2">
211<tr>
212<td class='online-navigation'><a rel="prev" title="12.10 multifile "
213 href="module-multifile.html"><img src='../icons/previous.png'
214 border='0' height='32' alt='Previous Page' width='32' /></A></td>
215<td class='online-navigation'><a rel="parent" title="12.10 multifile "
216 href="module-multifile.html"><img src='../icons/up.png'
217 border='0' height='32' alt='Up One Level' width='32' /></A></td>
218<td class='online-navigation'><a rel="next" title="12.10.2 MultiFile Example"
219 href="multifile-example.html"><img src='../icons/next.png'
220 border='0' height='32' alt='Next Page' width='32' /></A></td>
221<td align="center" width="100%">Python Library Reference</td>
222<td class='online-navigation'><a rel="contents" title="Table of Contents"
223 href="contents.html"><img src='../icons/contents.png'
224 border='0' height='32' alt='Contents' width='32' /></A></td>
225<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
226 border='0' height='32' alt='Module Index' width='32' /></a></td>
227<td class='online-navigation'><a rel="index" title="Index"
228 href="genindex.html"><img src='../icons/index.png'
229 border='0' height='32' alt='Index' width='32' /></A></td>
230</tr></table>
231<div class='online-navigation'>
232<b class="navlabel">Previous:</b>
233<a class="sectref" rel="prev" href="module-multifile.html">12.10 multifile </A>
234<b class="navlabel">Up:</b>
235<a class="sectref" rel="parent" href="module-multifile.html">12.10 multifile </A>
236<b class="navlabel">Next:</b>
237<a class="sectref" rel="next" href="multifile-example.html">12.10.2 MultiFile Example</A>
238</div>
239</div>
240<hr />
241<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
242</DIV>
243<!--End of Navigation Panel-->
244<ADDRESS>
245See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
246</ADDRESS>
247</BODY>
248</HTML>