Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
email.parser.BytesParser Class Reference

List of all members.

Public Member Functions

def __init__
def parse
def parsebytes

Public Attributes

 parser

Detailed Description

Definition at line 94 of file parser.py.


Constructor & Destructor Documentation

def email.parser.BytesParser.__init__ (   self,
  args,
  kw 
)
Parser of binary RFC 2822 and MIME email messages.

Creates an in-memory object tree representing the email message, which
can then be manipulated and turned over to a Generator to return the
textual representation of the message.

The input must be formatted as a block of RFC 2822 headers and header
continuation lines, optionally preceeded by a `Unix-from' header.  The
header block is terminated either by the end of the input or by a
blank line.

_class is the class to instantiate for new message objects when they
must be created.  This class must have a constructor that can take
zero arguments.  Default is Message.Message.

Definition at line 96 of file parser.py.

00096 
00097     def __init__(self, *args, **kw):
00098         """Parser of binary RFC 2822 and MIME email messages.
00099 
00100         Creates an in-memory object tree representing the email message, which
00101         can then be manipulated and turned over to a Generator to return the
00102         textual representation of the message.
00103 
00104         The input must be formatted as a block of RFC 2822 headers and header
00105         continuation lines, optionally preceeded by a `Unix-from' header.  The
00106         header block is terminated either by the end of the input or by a
00107         blank line.
00108 
00109         _class is the class to instantiate for new message objects when they
00110         must be created.  This class must have a constructor that can take
00111         zero arguments.  Default is Message.Message.
00112         """
00113         self.parser = Parser(*args, **kw)

Here is the caller graph for this function:


Member Function Documentation

def email.parser.BytesParser.parse (   self,
  fp,
  headersonly = False 
)
Create a message structure from the data in a binary file.

Reads all the data from the file and returns the root of the message
structure.  Optional headersonly is a flag specifying whether to stop
parsing after reading the headers or not.  The default is False,
meaning it parses the entire contents of the file.

Definition at line 114 of file parser.py.

00114 
00115     def parse(self, fp, headersonly=False):
00116         """Create a message structure from the data in a binary file.
00117 
00118         Reads all the data from the file and returns the root of the message
00119         structure.  Optional headersonly is a flag specifying whether to stop
00120         parsing after reading the headers or not.  The default is False,
00121         meaning it parses the entire contents of the file.
00122         """
00123         fp = TextIOWrapper(fp, encoding='ascii', errors='surrogateescape')
00124         with fp:
00125             return self.parser.parse(fp, headersonly)
00126 

Here is the caller graph for this function:

def email.parser.BytesParser.parsebytes (   self,
  text,
  headersonly = False 
)
Create a message structure from a byte string.

Returns the root of the message structure.  Optional headersonly is a
flag specifying whether to stop parsing after reading the headers or
not.  The default is False, meaning it parses the entire contents of
the file.

Definition at line 127 of file parser.py.

00127 
00128     def parsebytes(self, text, headersonly=False):
00129         """Create a message structure from a byte string.
00130 
00131         Returns the root of the message structure.  Optional headersonly is a
00132         flag specifying whether to stop parsing after reading the headers or
00133         not.  The default is False, meaning it parses the entire contents of
00134         the file.
00135         """
00136         text = text.decode('ASCII', errors='surrogateescape')
00137         return self.parser.parsestr(text, headersonly)

Member Data Documentation

Definition at line 112 of file parser.py.


The documentation for this class was generated from the following file: