diff options
author | Guido van Rossum <guido@python.org> | 1991-04-07 13:40:56 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1991-04-07 13:40:56 (GMT) |
commit | fa5406496750f9f0717457341041297b4173430f (patch) | |
tree | f07d715d5137bade53e714401dd69a2b54a22b72 /Lib | |
parent | fc61383fade19ebbee152b4c1110896a6196d1f6 (diff) | |
download | cpython-fa5406496750f9f0717457341041297b4173430f.zip cpython-fa5406496750f9f0717457341041297b4173430f.tar.gz cpython-fa5406496750f9f0717457341041297b4173430f.tar.bz2 |
Support packing whole trees.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/lib-old/packmail.py | 26 | ||||
-rw-r--r-- | Lib/packmail.py | 26 |
2 files changed, 52 insertions, 0 deletions
diff --git a/Lib/lib-old/packmail.py b/Lib/lib-old/packmail.py index c7bebe8..a964d6d 100644 --- a/Lib/lib-old/packmail.py +++ b/Lib/lib-old/packmail.py @@ -3,6 +3,7 @@ import mac import macpath from stat import ST_MTIME +import string # Pack one file def pack(outfp, file, name): @@ -46,3 +47,28 @@ def packnotolder(outfp, dirname, oldest): print 'No.' todo.sort() packsome(outfp, dirname, todo) + +# Pack a whole tree (no exceptions) +def packtree(outfp, dirname): + print 'packtree', dirname + outfp.write('mkdir ' + unixfix(dirname) + '\n') + names = mac.listdir(dirname) + subdirs = [] + for name in names: + fullname = macpath.cat(dirname, name) + if macpath.isdir(fullname): + subdirs.append(fullname) + else: + print 'pack', fullname + pack(outfp, fullname, unixfix(fullname)) + for subdirname in subdirs: + packtree(outfp, subdirname) + +def unixfix(name): + comps = string.splitfields(name, ':') + res = '' + for comp in comps: + if comp: + if res: res = res + '/' + res = res + comp + return res diff --git a/Lib/packmail.py b/Lib/packmail.py index c7bebe8..a964d6d 100644 --- a/Lib/packmail.py +++ b/Lib/packmail.py @@ -3,6 +3,7 @@ import mac import macpath from stat import ST_MTIME +import string # Pack one file def pack(outfp, file, name): @@ -46,3 +47,28 @@ def packnotolder(outfp, dirname, oldest): print 'No.' todo.sort() packsome(outfp, dirname, todo) + +# Pack a whole tree (no exceptions) +def packtree(outfp, dirname): + print 'packtree', dirname + outfp.write('mkdir ' + unixfix(dirname) + '\n') + names = mac.listdir(dirname) + subdirs = [] + for name in names: + fullname = macpath.cat(dirname, name) + if macpath.isdir(fullname): + subdirs.append(fullname) + else: + print 'pack', fullname + pack(outfp, fullname, unixfix(fullname)) + for subdirname in subdirs: + packtree(outfp, subdirname) + +def unixfix(name): + comps = string.splitfields(name, ':') + res = '' + for comp in comps: + if comp: + if res: res = res + '/' + res = res + comp + return res |