<!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN">
<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=
"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 name='aesop' content='information'
/>
<title>12.10.1 MultiFile Objects
</title>
<div id='top-navigation-panel' xml:id='top-navigation-panel'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<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>
<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>
<!--End of Navigation Panel-->
<H2><A NAME=
"SECTION00141010000000000000000"></A><A NAME=
"MultiFile-objects"></A>
12.10.1 MultiFile Objects
A
<tt class=
"class">MultiFile
</tt> instance has the following methods:
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4060' xml:id='l2h-
4060'
class=
"method">readline
</tt></b>(
</nobr></td>
<td><var>str
</var>)
</td></tr></table></dt>
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><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4061' xml:id='l2h-
4061'
class=
"method">readlines
</tt></b>(
</nobr></td>
<td><var>str
</var>)
</td></tr></table></dt>
Return all lines remaining in this part as a list of strings.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4062' xml:id='l2h-
4062'
class=
"method">read
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
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><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4063' xml:id='l2h-
4063'
class=
"method">seek
</tt></b>(
</nobr></td>
<td><var>pos
</var><big>[
</big><var>, whence
</var><big>]
</big><var></var>)
</td></tr></table></dt>
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
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4064' xml:id='l2h-
4064'
class=
"method">tell
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
Return the file position relative to the start of the current section.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4065' xml:id='l2h-
4065'
class=
"method">next
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
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><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4066' xml:id='l2h-
4066'
class=
"method">is_data
</tt></b>(
</nobr></td>
<td><var>str
</var>)
</td></tr></table></dt>
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.
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><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4067' xml:id='l2h-
4067'
class=
"method">push
</tt></b>(
</nobr></td>
<td><var>str
</var>)
</td></tr></table></dt>
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
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><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4068' xml:id='l2h-
4068'
class=
"method">pop
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
Pop a section boundary. This boundary will no longer be interpreted
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4069' xml:id='l2h-
4069'
class=
"method">section_divider
</tt></b>(
</nobr></td>
<td><var>str
</var>)
</td></tr></table></dt>
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><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4070' xml:id='l2h-
4070'
class=
"method">end_marker
</tt></b>(
</nobr></td>
<td><var>str
</var>)
</td></tr></table></dt>
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.
Finally,
<tt class=
"class">MultiFile
</tt> instances have two public instance variables:
<dl><dt><b><tt id='l2h-
4071' xml:id='l2h-
4071'
class=
"member">level
</tt></b></dt>
Nesting depth of the current part.
<dl><dt><b><tt id='l2h-
4072' xml:id='l2h-
4072'
class=
"member">last
</tt></b></dt>
True if the last end-of-file was for an end-of-message marker.
<div class='online-navigation'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<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>
<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>
<span class=
"release-info">Release
2.4.2, documentation updated on
28 September
2005.
</span>
<!--End of Navigation Panel-->
See
<i><a href=
"about.html">About this document...
</a></i> for information on suggesting changes.