[Python-checkins] python/dist/src/Lib/email Generator.py,1.8,1.9

bwarsaw@users.sourceforge.net bwarsaw@users.sourceforge.net
Sun, 02 Jun 2002 12:02:39 -0700


Update of /cvsroot/python/python/dist/src/Lib/email
In directory usw-pr-cvs1:/tmp/cvs-serv24576/email

Modified Files:
	Generator.py 
Log Message:
flatten(): Renamed from __call__() which is (silently) deprecated.
__call__() can be 2-3x slower than the equivalent normal method.

_handle_message(): The structure of message/rfc822 message has
changed.  Now parent's payload is a list of length 1, and the zeroth
element is the Message sub-object.  Adjust the printing of such
message trees to reflect this change.


Index: Generator.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/Generator.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Generator.py	10 Apr 2002 21:01:30 -0000	1.8
--- Generator.py	2 Jun 2002 19:02:37 -0000	1.9
***************
*** 61,65 ****
          self._fp.write(s)
  
!     def __call__(self, msg, unixfrom=0):
          """Print the message object tree rooted at msg to the output file
          specified when the Generator instance was created.
--- 61,65 ----
          self._fp.write(s)
  
!     def flatten(self, msg, unixfrom=0):
          """Print the message object tree rooted at msg to the output file
          specified when the Generator instance was created.
***************
*** 79,82 ****
--- 79,85 ----
          self._write(msg)
  
+     # For backwards compatibility, but this is slower
+     __call__ = flatten
+ 
      #
      # Protected interface - undocumented ;/
***************
*** 255,259 ****
              s = StringIO()
              g = self.__class__(s, self._mangle_from_, self.__maxheaderlen)
!             g(part, unixfrom=0)
              msgtexts.append(s.getvalue())
          # Now make sure the boundary we've selected doesn't appear in any of
--- 258,262 ----
              s = StringIO()
              g = self.__class__(s, self._mangle_from_, self.__maxheaderlen)
!             g.flatten(part, unixfrom=0)
              msgtexts.append(s.getvalue())
          # Now make sure the boundary we've selected doesn't appear in any of
***************
*** 303,307 ****
              s = StringIO()
              g = self.__class__(s, self._mangle_from_, self.__maxheaderlen)
!             g(part, unixfrom=0)
              text = s.getvalue()
              lines = text.split('\n')
--- 306,310 ----
              s = StringIO()
              g = self.__class__(s, self._mangle_from_, self.__maxheaderlen)
!             g.flatten(part, unixfrom=0)
              text = s.getvalue()
              lines = text.split('\n')
***************
*** 319,326 ****
          s = StringIO()
          g = self.__class__(s, self._mangle_from_, self.__maxheaderlen)
!         # A message/rfc822 should contain a scalar payload which is another
!         # Message object.  Extract that object, stringify it, and write that
!         # out.
!         g(msg.get_payload(), unixfrom=0)
          self._fp.write(s.getvalue())
  
--- 322,330 ----
          s = StringIO()
          g = self.__class__(s, self._mangle_from_, self.__maxheaderlen)
!         # The payload of a message/rfc822 part should be a multipart sequence
!         # of length 1.  The zeroth element of the list should be the Message
!         # object for the subpart.Extract that object, stringify it, and write
!         # that out.
!         g.flatten(msg.get_payload(0), unixfrom=0)
          self._fp.write(s.getvalue())