[Python-checkins] python/dist/src/Lib/email Utils.py,1.18,1.19

barry@users.sourceforge.net barry@users.sourceforge.net
Sat, 28 Sep 2002 13:49:59 -0700


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

Modified Files:
	Utils.py 
Log Message:
Use True/False everywhere, and other code cleanups.



Index: Utils.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/Utils.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** Utils.py	11 Sep 2002 02:22:48 -0000	1.18
--- Utils.py	28 Sep 2002 20:49:57 -0000	1.19
***************
*** 23,26 ****
--- 23,32 ----
  
  try:
+     True, False
+ except NameError:
+     True = 1
+     False = 0
+ 
+ try:
      from quopri import decodestring as _qdecode
  except ImportError:
***************
*** 31,40 ****
          if not s:
              return s
-         hasnewline = (s[-1] == '\n')
          infp = StringIO(s)
          outfp = StringIO()
          _quopri.decode(infp, outfp)
          value = outfp.getvalue()
!         if not hasnewline and value[-1] =='\n':
              return value[:-1]
          return value
--- 37,45 ----
          if not s:
              return s
          infp = StringIO(s)
          outfp = StringIO()
          _quopri.decode(infp, outfp)
          value = outfp.getvalue()
!         if not s.endswith('\n') and value.endswith('\n'):
              return value[:-1]
          return value
***************
*** 68,74 ****
      if not s:
          return s
-     hasnewline = (s[-1] == '\n')
      value = base64.decodestring(s)
!     if not hasnewline and value[-1] == '\n':
          return value[:-1]
      return value
--- 73,78 ----
      if not s:
          return s
      value = base64.decodestring(s)
!     if not s.endswith('\n') and value.endswith('\n'):
          return value[:-1]
      return value
***************
*** 89,93 ****
      """The inverse of parseaddr(), this takes a 2-tuple of the form
      (realname, email_address) and returns the string value suitable
!     for an RFC 2822 From:, To: or Cc:.
  
      If the first element of pair is false, then the second element is
--- 93,97 ----
      """The inverse of parseaddr(), this takes a 2-tuple of the form
      (realname, email_address) and returns the string value suitable
!     for an RFC 2822 From, To or Cc header.
  
      If the first element of pair is false, then the second element is
***************
*** 171,175 ****
  
  
! def formatdate(timeval=None, localtime=0):
      """Returns a date string as specified by RFC 2822, e.g.:
  
--- 175,179 ----
  
  
! def formatdate(timeval=None, localtime=False):
      """Returns a date string as specified by RFC 2822, e.g.:
  
***************
*** 179,183 ****
      gmtime() and localtime(), otherwise the current time is used.
  
!     Optional localtime is a flag that when true, interprets timeval, and
      returns a date relative to the local timezone instead of UTC, properly
      taking daylight savings time into account.
--- 183,187 ----
      gmtime() and localtime(), otherwise the current time is used.
  
!     Optional localtime is a flag that when True, interprets timeval, and
      returns a date relative to the local timezone instead of UTC, properly
      taking daylight savings time into account.