<!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.gif" /> <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="multifile-example.html"> <LINK rel="prev" href="module-multifile.html"> <LINK rel="parent" href="module-multifile.html"> <LINK rel="next" href="multifile-example.html"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name='aesop' content='information' /> <META name="description" content="MultiFile Objects "> <META name="keywords" content="lib"> <META name="resource-type" content="document"> <META name="distribution" content="global"> <title>12.10.1 MultiFile Objects </title> </head> <body> <DIV CLASS="navigation"> <div id='top-navigation-panel'> <table align="center" width="100%" cellpadding="0" cellspacing="2"> <tr> <td class='online-navigation'><a rel="prev" title="12.10 multifile " href="module-multifile.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="12.10 multifile " href="module-multifile.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="12.10.2 MultiFile Example" href="multifile-example.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-multifile.html">12.10 multifile </A> <b class="navlabel">Up:</b> <a class="sectref" rel="parent" href="module-multifile.html">12.10 multifile </A> <b class="navlabel">Next:</b> <a class="sectref" rel="next" href="multifile-example.html">12.10.2 MultiFile Example</A> </div> <hr /></div> </DIV> <!--End of Navigation Panel--> <H2><A NAME="SECTION00141010000000000000000"><!--x--></A><A NAME="MultiFile-objects"><!--z--></A> <BR> 12.10.1 MultiFile Objects </H2> <P> A <tt class="class">MultiFile</tt> instance has the following methods: <P> <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> <td><nobr><b><tt id='l2h-3770' class="method">readline</tt></b>(</nobr></td> <td><var>str</var>)</td></tr></table></dt> <dd> Read a line. If the line is data (not a section-divider or end-marker or real EOF) return it. If the line matches the most-recently-stacked boundary, return <code>''</code> and set <code>self.last</code> to 1 or 0 according as the match is or is not an end-marker. If the line matches any other stacked boundary, raise an error. On encountering end-of-file on the underlying stream object, the method raises <tt class="exception">Error</tt> unless all boundaries have been popped. </dl> <P> <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> <td><nobr><b><tt id='l2h-3771' class="method">readlines</tt></b>(</nobr></td> <td><var>str</var>)</td></tr></table></dt> <dd> Return all lines remaining in this part as a list of strings. </dl> <P> <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> <td><nobr><b><tt id='l2h-3772' class="method">read</tt></b>(</nobr></td> <td>)</td></tr></table></dt> <dd> Read all lines, up to the next section. Return them as a single (multiline) string. Note that this doesn't take a size argument! </dl> <P> <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> <td><nobr><b><tt id='l2h-3773' class="method">seek</tt></b>(</nobr></td> <td><var>pos</var><big>[</big><var>, whence</var><big>]</big>)</td></tr></table></dt> <dd> Seek. Seek indices are relative to the start of the current section. The <var>pos</var> and <var>whence</var> arguments are interpreted as for a file seek. </dl> <P> <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> <td><nobr><b><tt id='l2h-3774' class="method">tell</tt></b>(</nobr></td> <td>)</td></tr></table></dt> <dd> Return the file position relative to the start of the current section. </dl> <P> <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> <td><nobr><b><tt id='l2h-3775' class="method">next</tt></b>(</nobr></td> <td>)</td></tr></table></dt> <dd> Skip lines to the next section (that is, read lines until a section-divider or end-marker has been consumed). Return true if there is such a section, false if an end-marker is seen. Re-enable the most-recently-pushed boundary. </dl> <P> <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> <td><nobr><b><tt id='l2h-3776' class="method">is_data</tt></b>(</nobr></td> <td><var>str</var>)</td></tr></table></dt> <dd> Return true if <var>str</var> is data and false if it might be a section boundary. As written, it tests for a prefix other than <code>'-</code><code>-'</code> at start of line (which all MIME boundaries have) but it is declared so it can be overridden in derived classes. <P> Note that this test is used intended as a fast guard for the real boundary tests; if it always returns false it will merely slow processing, not cause it to fail. </dl> <P> <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> <td><nobr><b><tt id='l2h-3777' class="method">push</tt></b>(</nobr></td> <td><var>str</var>)</td></tr></table></dt> <dd> Push a boundary string. When an appropriately decorated version of this boundary is found as an input line, it will be interpreted as a section-divider or end-marker. All subsequent reads will return the empty string to indicate end-of-file, until a call to <tt class="method">pop()</tt> removes the boundary a or <tt class="method">next()</tt> call reenables it. <P> It is possible to push more than one boundary. Encountering the most-recently-pushed boundary will return EOF; encountering any other boundary will raise an error. </dl> <P> <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> <td><nobr><b><tt id='l2h-3778' class="method">pop</tt></b>(</nobr></td> <td>)</td></tr></table></dt> <dd> Pop a section boundary. This boundary will no longer be interpreted as EOF. </dl> <P> <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> <td><nobr><b><tt id='l2h-3779' class="method">section_divider</tt></b>(</nobr></td> <td><var>str</var>)</td></tr></table></dt> <dd> Turn a boundary into a section-divider line. By default, this method prepends <code>'-</code><code>-'</code> (which MIME section boundaries have) but it is declared so it can be overridden in derived classes. This method need not append LF or CR-LF, as comparison with the result ignores trailing whitespace. </dl> <P> <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> <td><nobr><b><tt id='l2h-3780' class="method">end_marker</tt></b>(</nobr></td> <td><var>str</var>)</td></tr></table></dt> <dd> Turn a boundary string into an end-marker line. By default, this method prepends <code>'-</code><code>-'</code> and appends <code>'-</code><code>-'</code> (like a MIME-multipart end-of-message marker) but it is declared so it can be overridden in derived classes. This method need not append LF or CR-LF, as comparison with the result ignores trailing whitespace. </dl> <P> Finally, <tt class="class">MultiFile</tt> instances have two public instance variables: <P> <dl><dt><b><tt id='l2h-3781' class="member">level</tt></b></dt> <dd> Nesting depth of the current part. </dl> <P> <dl><dt><b><tt id='l2h-3782' class="member">last</tt></b></dt> <dd> True if the last end-of-file was for an end-of-message marker. </dl> <P> <DIV CLASS="navigation"> <div class='online-navigation'><hr /> <table align="center" width="100%" cellpadding="0" cellspacing="2"> <tr> <td class='online-navigation'><a rel="prev" title="12.10 multifile " rel="prev" title="12.10 multifile " href="module-multifile.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="12.10 multifile " rel="parent" title="12.10 multifile " href="module-multifile.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="12.10.2 MultiFile Example" rel="next" title="12.10.2 MultiFile Example" href="multifile-example.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" 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" 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-multifile.html">12.10 multifile </A> <b class="navlabel">Up:</b> <a class="sectref" rel="parent" href="module-multifile.html">12.10 multifile </A> <b class="navlabel">Next:</b> <a class="sectref" rel="next" href="multifile-example.html">12.10.2 MultiFile Example</A> </div> </div> <hr /> <span class="release-info">Release 2.3.4, documentation updated on May 20, 2004.</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>