[Python-checkins] CVS: python/dist/src/Lib/email Parser.py,1.4,1.5

Barry Warsaw bwarsaw@users.sourceforge.net
2001年10月11日 08:43:02 -0700


Update of /cvsroot/python/python/dist/src/Lib/email
In directory usw-pr-cvs1:/tmp/cvs-serv27728
Modified Files:
	Parser.py 
Log Message:
HeaderParser: A new subclass of Parser which only parses the message
headers. It does not parse the body of the message, instead simply
assigning it as a string to the container's payload. This can be much
faster when you're only interested in a message's header.
Index: Parser.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/Parser.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Parser.py	2001年10月04日 17:05:11	1.4
--- Parser.py	2001年10月11日 15:43:00	1.5
***************
*** 159,160 ****
--- 159,176 ----
 else:
 container.add_payload(fp.read())
+ 
+ 
+ 
+ class HeaderParser(Parser):
+ """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.
+ """
+ def _parsebody(self, container, fp):
+ # Consume but do not parse, the body
+ container.set_payload(fp.read())

AltStyle によって変換されたページ (->オリジナル) /