summaryrefslogtreecommitdiffstats
path: root/Lib/packmail.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1990-12-26 15:40:07 (GMT)
committerGuido van Rossum <guido@python.org>1990-12-26 15:40:07 (GMT)
commit217a5fa3c33ae58c1fe420f94eeb7e806961c3c1 (patch)
treeb0bdfd34e5a72346a63106565acc7622a28b2a30 /Lib/packmail.py
parent66a07c07a5b7b1ce7150d5c5c1a0998d062e452e (diff)
downloadcpython-217a5fa3c33ae58c1fe420f94eeb7e806961c3c1.zip
cpython-217a5fa3c33ae58c1fe420f94eeb7e806961c3c1.tar.gz
cpython-217a5fa3c33ae58c1fe420f94eeb7e806961c3c1.tar.bz2
Initial revision
Diffstat (limited to 'Lib/packmail.py')
-rw-r--r--Lib/packmail.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/Lib/packmail.py b/Lib/packmail.py
new file mode 100644
index 0000000..c7bebe8
--- /dev/null
+++ b/Lib/packmail.py
@@ -0,0 +1,48 @@
+# Module 'packmail' -- create a shell script out of some files.
+
+import mac
+import macpath
+from stat import ST_MTIME
+
+# Pack one file
+def pack(outfp, file, name):
+ fp = open(file, 'r')
+ outfp.write('sed "s/^X//" >' + name + ' <<"!"\n')
+ while 1:
+ line = fp.readline()
+ if not line: break
+ if line[-1:] <> '\n':
+ line = line + '\n'
+ outfp.write('X' + line)
+ outfp.write('!\n')
+
+# Pack some files from a directory
+def packsome(outfp, dirname, names):
+ for name in names:
+ print name
+ file = macpath.cat(dirname, name)
+ pack(outfp, file, name)
+
+# Pack all files from a directory
+def packall(outfp, dirname):
+ names = mac.listdir(dirname)
+ names.sort()
+ packsome(outfp, dirname, names)
+
+# Pack all files from a directory that are not older than a give one
+def packnotolder(outfp, dirname, oldest):
+ names = mac.listdir(dirname)
+ oldest = macpath.cat(dirname, oldest)
+ st = mac.stat(oldest)
+ mtime = st[ST_MTIME]
+ todo = []
+ for name in names:
+ print name, '...',
+ st = mac.stat(macpath.cat(dirname, name))
+ if st[ST_MTIME] >= mtime:
+ print 'Yes.'
+ todo.append(name)
+ else:
+ print 'No.'
+ todo.sort()
+ packsome(outfp, dirname, todo)