GNU Info

Info Node: (python2.1-lib.info)multifile

(python2.1-lib.info)multifile


Next: binhex Prev: MimeWriter Up: Internet Data Handling
Enter node , (file) or (file)node

Support for files containing distinct parts
===========================================

Support for reading files which contain distinct parts, such as some
MIME data.

This manual section was written by Eric S. Raymond
<esr@snark.thyrsus.com>.
The `MultiFile' object enables you to treat sections of a text file as
file-like input objects, with `''' being returned by `readline()' when
a given delimiter pattern is encountered.  The defaults of this class
are designed to make it useful for parsing MIME multipart messages, but
by subclassing it and overriding methods it can be easily adapted for
more general use.

`MultiFile(fp[, seekable])'
     Create a multi-file.  You must instantiate this class with an input
     object argument for the `MultiFile' instance to get lines from,
     such as as a file object returned by `open()'.

     `MultiFile' only ever looks at the input object's `readline()',
     `seek()' and `tell()' methods, and the latter two are only needed
     if you want random access to the individual MIME parts. To use
     `MultiFile' on a non-seekable stream object, set the optional
     SEEKABLE argument to false; this will prevent using the input
     object's `seek()' and `tell()' methods.

It will be useful to know that in `MultiFile''s view of the world, text
is composed of three kinds of lines: data, section-dividers, and
end-markers.  MultiFile is designed to support parsing of messages that
may have multiple nested message parts, each with its own pattern for
section-divider and end-marker lines.

MultiFile Objects
MultiFile Example

automatically generated by info2www version 1.2.2.9