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

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


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

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


Index: base64MIME.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/base64MIME.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** base64MIME.py	2 Jun 2002 19:08:31 -0000	1.4
--- base64MIME.py	28 Sep 2002 20:59:12 -0000	1.5
***************
*** 42,45 ****
--- 42,51 ----
  MISC_LEN = 7
  
+ try:
+     True, False
+ except NameError:
+     True = 1
+     False = 0
+ 
  
  
***************
*** 57,62 ****
  
  
! def header_encode(header, charset='iso-8859-1', keep_eols=0, maxlinelen=76,
!                   eol=NL):
      """Encode a single header line with Base64 encoding in a given charset.
  
--- 63,68 ----
  
  
! def header_encode(header, charset='iso-8859-1', keep_eols=False,
!                   maxlinelen=76, eol=NL):
      """Encode a single header line with Base64 encoding in a given charset.
  
***************
*** 70,74 ****
      End-of-line characters (\\r, \\n, \\r\\n) will be automatically converted
      to the canonical email line separator \\r\\n unless the keep_eols
!     parameter is set to true (the default is false).
  
      Each line of the header will be terminated in the value of eol, which
--- 76,80 ----
      End-of-line characters (\\r, \\n, \\r\\n) will be automatically converted
      to the canonical email line separator \\r\\n unless the keep_eols
!     parameter is True (the default is False).
  
      Each line of the header will be terminated in the value of eol, which
***************
*** 107,111 ****
      for line in base64ed:
          # Ignore the last character of each line if it is a newline
!         if line[-1] == NL:
              line = line[:-1]
          # Add the chrome
--- 113,117 ----
      for line in base64ed:
          # Ignore the last character of each line if it is a newline
!         if line.endswith(NL):
              line = line[:-1]
          # Add the chrome
***************
*** 118,122 ****
  
  
! def encode(s, binary=1, maxlinelen=76, eol=NL):
      """Encode a string with base64.
  
--- 124,128 ----
  
  
! def encode(s, binary=True, maxlinelen=76, eol=NL):
      """Encode a string with base64.
  
***************
*** 124,128 ****
      76 characters).
  
!     If binary is false, end-of-line characters will be converted to the
      canonical email end-of-line sequence \\r\\n.  Otherwise they will be left
      verbatim (this is the default).
--- 130,134 ----
      76 characters).
  
!     If binary is False, end-of-line characters will be converted to the
      canonical email end-of-line sequence \\r\\n.  Otherwise they will be left
      verbatim (this is the default).
***************
*** 144,148 ****
          # adding a newline to the encoded string?
          enc = b2a_base64(s[i:i + max_unencoded])
!         if enc[-1] == NL and eol <> NL:
              enc = enc[:-1] + eol
          encvec.append(enc)
--- 150,154 ----
          # adding a newline to the encoded string?
          enc = b2a_base64(s[i:i + max_unencoded])
!         if enc.endswith(NL) and eol <> NL:
              enc = enc[:-1] + eol
          encvec.append(enc)