[Patches] [ python-Patches-445433 ] a getPart method for mimetools.Message
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 27 Jul 2001 23:31:07 -0700
Patches item #445433, was opened at 2001-07-27 23:31
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=445433&group_id=5470
Category: library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Richard Jones (richard)
Assigned to: Nobody/Anonymous (nobody)
Summary: a getPart method for mimetools.Message
Initial Comment:
This is a getPart method for the mimetools.Message
class. The code comes from the roundup project
(roundup.sf.net) ... it seems odd that
mimetools.Message doesn't provide this
out-of-the-box. Anyway, it's simple enough. There is
a unit test for this code in the roundup test
directory.
class Message(mimetools.Message):
def getPart(self)
boundary = self.getparam('boundary')
mid, end = '--'+boundary, '--'+boundary+'--'
s = cStringIO.StringIO()
while 1:
line = self.fp.readline()
if not line:
break
if line.strip() in (mid, end):
break
s.write(line)
if not s.getvalue().strip():
return None
s.seek(0)
return Message(s)
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=445433&group_id=5470