diffs to uu.py

lance@fox.com
Fri, 9 Sep 94 10:12:27 PDT

Here are some diffs to uu.py. These were given to me by Guido.
These diffs will be included in the next release.

===================================================================
RCS file: /u/lance/CVS/python/Lib/uu.py,v
retrieving revision 1.1
diff -b -c -r1.1 uu.py
*** 1.1 1994/09/02 20:14:44
--- uu.py 1994/09/09 15:18:19
***************
*** 19,28 ****

# This file implements the UUencode and UUdecode functions.

! # None = encode(filename, mode, in_file, out_file)
! # None = decode(filename, mode, in_file)
! # None = decode(in_file, out_file)
! # None = decode(in_file)

# encode a single char to always be printable
def _ENC(ch):
--- 19,28 ----

# This file implements the UUencode and UUdecode functions.

! # encode(filename, mode, in_file, out_file)
! # decode(filename, mode, in_file)
! # decode(in_file, out_file)
! # decode(in_file)

# encode a single char to always be printable
def _ENC(ch):
***************
*** 90,96 ****

# input 4 chars encoded, output 3 chars unencoded
def _outdec(str):
- print str
if len(str) > 4:
raise ValueError, 'can only accept strings of 4 chars'
p0, p1, p2, p3 = 0, 0, 0, 0
--- 90,95 ----
***************
*** 122,130 ****
i = i + 4
return rtn[0:length]

! # None = decode(filename, mode, in_file)
! # None = decode(in_file, out_file)
! # None = decode(in_file)
def decode(*args):
ok = 1
_setup = None
--- 121,129 ----
i = i + 4
return rtn[0:length]

! # decode(filename, mode, in_file)
! # decode(in_file, out_file)
! # decode(in_file)
def decode(*args):
ok = 1
_setup = None
***************
*** 174,180 ****
i = strop.strip(i)
if 'begin' != i[:5]:
raise IOError, 'input file not in UUencoded format'
! dummy, mode, filename = strop.split(i)
out_file = open(filename,'w',mode)
_out_file_orig = 0
return (out_file,_out_file_orig)
--- 173,180 ----
i = strop.strip(i)
if 'begin' != i[:5]:
raise IOError, 'input file not in UUencoded format'
! [dummy, mode, filename] = strop.split(i)
! mode = strop.atoi(mode, 8)
out_file = open(filename,'w',mode)
_out_file_orig = 0
return (out_file,_out_file_orig)
***************
*** 189,191 ****
--- 189,214 ----
out_file.close()
del out_file
return None
+
+ def test():
+ import sys
+ if sys.argv[1:2] == ['-d']:
+ if sys.argv[2:]:
+ decode(open(sys.argv[2]), sys.stdout)
+ else:
+ decode(sys.stdin, sys.stdout)
+ elif sys.argv[1:2] == ['-e']:
+ if sys.argv[2:]:
+ file = sys.argv[2]
+ fp = open(file)
+ else:
+ file = '-'
+ fp = sys.stdin
+ encode(file, 0644, fp, sys.stdout)
+ else:
+ print 'usage: uu -d [file]; (to decode)'
+ print 'or: uu -e [file]; (to encode)'
+ sys.exit(2)
+
+ if __name__ == '__main__':
+ test()

--
Lance Ellinghouse                lance@fox.com