--- /opt/local/Library/Frameworks/Python.framework/Versions/Current/lib/python2.4/uu.py.orig 2007-08-25 23:42:35.000000000 -0400 +++ /opt/local/Library/Frameworks/Python.framework/Versions/Current/lib/python2.4/uu.py 2007-08-26 11:42:54.000000000 -0400 @@ -18,6 +18,9 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # +# Modified by Gregory Dudek, August 2007: +# - added support for decoding of base54 uuencoded files. +# # Modified by Jack Jansen, CWI, July 1995: # - Use binascii module to do the actual line-by-line conversion # between ascii and binary. This results in a 1000-fold speedup. The C @@ -81,7 +84,7 @@ out_file.write(' \nend\n') -def decode(in_file, out_file=None, mode=None, quiet=0): +def decode(in_file, out_file=None, mode=None, quiet=0, base64=0): """Decode uuencoded file""" # # Open the input file, if needed. @@ -100,9 +103,10 @@ if hdr[:5] != 'begin': continue hdrfields = hdr.split(" ", 2) - if len(hdrfields) == 3 and hdrfields[0] == 'begin': + if len(hdrfields) == 3 and (hdrfields[0] == 'begin' or hdrfields[0] == 'begin-base64'): try: int(hdrfields[1], 8) + if hdrfields[0] == 'begin-base64': base64=1 break except ValueError: pass @@ -130,11 +134,13 @@ s = in_file.readline() while s and s.strip() != 'end': try: - data = binascii.a2b_uu(s) + if base64: data = binascii.a2b_base64(s) + else: data = binascii.a2b_uu(s) except binascii.Error, v: # Workaround for broken uuencoders by /Fredrik Lundh nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3 - data = binascii.a2b_uu(s[:nbytes]) + if base64: data = binascii.a2b_base64(s[:nbytes]) + else: data = binascii.a2b_uu(s[:nbytes]) if not quiet: sys.stderr.write("Warning: %s\n" % str(v)) out_file.write(data)