summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-04-08 19:46:02 (GMT)
committerGuido van Rossum <guido@python.org>1997-04-08 19:46:02 (GMT)
commit2ebaa1796e654e94617745ba22fd0ccaf70c91d9 (patch)
tree0643c25dba83b141cf4d6b779e6be10dd411772c /Lib
parent64639202baac74185373f77f9cfa15b0bed9e007 (diff)
downloadcpython-2ebaa1796e654e94617745ba22fd0ccaf70c91d9.zip
cpython-2ebaa1796e654e94617745ba22fd0ccaf70c91d9.tar.gz
cpython-2ebaa1796e654e94617745ba22fd0ccaf70c91d9.tar.bz2
Search for a valid begin line instead of requiring the first line.
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/uu.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/Lib/uu.py b/Lib/uu.py
index 5644803..a9e1c5b 100755
--- a/Lib/uu.py
+++ b/Lib/uu.py
@@ -85,18 +85,25 @@ def decode(in_file, out_file=None, mode=None):
elif type(in_file) == type(''):
in_file = open(in_file)
#
- # Read the header line, and fill in optional args if needed
- #
- hdr = in_file.readline()
- if not hdr:
- raise Error, 'Empty input file'
- hdrfields = string.split(hdr)
- if len(hdrfields) <> 3 or hdrfields[0] <> 'begin':
- raise Error, ('Incorrect uu header line', hdr)
+ # Read until a begin is encountered or we've exhausted the file
+ #
+ while (1):
+ hdr = in_file.readline()
+ if not hdr:
+ raise Error, 'No valid begin line found in input file'
+ if hdr[:5] != 'begin':
+ continue
+ hdrfields = string.split(hdr)
+ if len(hdrfields) == 3 and hdrfields[0] == 'begin':
+ try:
+ string.atoi(hdrfields[1], 8)
+ break
+ except ValueError:
+ pass
if out_file == None:
out_file = hdrfields[2]
if mode == None:
- mode = string.atoi(hdrfields[1])
+ mode = string.atoi(hdrfields[1], 8)
#
# Open the output file
#