;ς ίp>c@s»dZdkZdklZdklZdklZdklZdZ dZ ye e fWne j odZ d Z nXeid ƒZd fd „ƒYZd efd„ƒYZdS(s.A parser of RFC 2822 and MIME email messages. N(sStringIO(sListType(sErrors(sMessagess iis | | sParsercBsGtZeied„Zed„Zed„Zd„Zed„Z RS(NcCs||_||_dS(s"Parser of 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 string 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 string 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. Optional strict tells the parser to be strictly RFC compliant or to be more forgiving in parsing of ill-formatted MIME documents. When non-strict mode is used, the parser will try to make up for missing or erroneous boundaries and other peculiarities seen in the wild. Default is non-strict parsing. N(s_classsselfsstricts_strict(sselfs_classsstrict((s./usr/pkg/lib/mailman/pythonlib/email/Parser.pys__init__s cCsE|iƒ}|i||ƒ}| o|i|||ƒn|SdS(s\Create a message structure from the data in a 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. N(sselfs_classsroots _parseheaderssfps firstbodylines headersonlys _parsebody(sselfsfps headersonlysroots firstbodyline((s./usr/pkg/lib/mailman/pythonlib/email/Parser.pysparse5s  cCs|it|ƒd|ƒSdS(s-Create a message structure from a 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. s headersonlyN(sselfsparsesStringIOstexts headersonly(sselfstexts headersonly((s./usr/pkg/lib/mailman/pythonlib/email/Parser.pysparsestrCsc CsΝd}g}d}t}xŒto„|iƒ}| oPn|i ƒd}| oPn|d7}|i dƒoE|djo|i |ƒqq·|iotidƒ‚q·qn|ddjo/| otidƒ‚n|i|ƒqn|idƒ}|djoP|iotid |ƒ‚qc|djo |i d ƒoqqc|}Pn|oti|ƒ||s)(?P[ \t]*)s#Couldn't find starting boundary: %sissepswss(?P | | )s&Couldn't find terminating boundary: %ss(?P | | ){2}$s(?P | | )$s2No terminating boundary and no trailing empty lines[ \t]*is headersonlysmessage/rfc822smessages multiparts*multipart message with no defined boundarysmessage/delivery-status(8s containers get_boundarysboundarysget_content_typesisdigestsNonespreamblesepilogues separatorsfpsreadspayloads firstbodylinesressearchsescapesmosselfs_strictsErrorss BoundaryErrors set_payloadsstartslensgroupsNLCREscompilescres terminatorslinesepsendssplitspartssparts startswiths_classsmsgobjsparthdrssparsestrsset_default_typesget_content_maintypesmaintypes submsgobjsattachs get_main_typesget_typesblockssTruesblockmsgs _parseheaderssappendsparsesmsgsHeaderParseErrors _parsebodystext(sselfs containersfps firstbodylinestexts submsgobjs terminatorsblockssblockmsgsmaintypespayloadspreambleslinesepsstartspartssmsgsboundarysmsgobjspartsepiloguesmos separatorscresisdigestsparthdrs((s./usr/pkg/lib/mailman/pythonlib/email/Parser.pys _parsebodys’          ,             ( s__name__s __module__sMessagesFalses__init__sparsesparsestrs _parseheaderssNones _parsebody(((s./usr/pkg/lib/mailman/pythonlib/email/Parser.pysParsers   Bs HeaderParsercBstZdZed„ZRS(s‹A subclass of Parser, this one only meaningfully parses message headers. This class can be used if all you're interested in is the headers of a message. While it consumes the message body, it does not parse it, but simply makes it available as a string payload. Parsing with this subclass can be considerably faster if all you're interested in is the message headers. cCs<|iƒ}|tj o|d|}n|i|ƒdS(Ns (sfpsreadstexts firstbodylinesNones containers set_payload(sselfs containersfps firstbodylinestext((s./usr/pkg/lib/mailman/pythonlib/email/Parser.pys _parsebodys  (s__name__s __module__s__doc__sNones _parsebody(((s./usr/pkg/lib/mailman/pythonlib/email/Parser.pys HeaderParsers (s__doc__sres cStringIOsStringIOstypessListTypesemailsErrorssMessages EMPTYSTRINGsNLsTruesFalses NameErrorscompilesNLCREsParsers HeaderParser( sErrorssNLsStringIOsParsers EMPTYSTRINGsres HeaderParsersNLCREsListTypesFalsesMessagesTrue((s./usr/pkg/lib/mailman/pythonlib/email/Parser.pys?s      ϊ