summaryrefslogtreecommitdiffstats
path: root/Mac/scripts
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1995-08-14 12:19:20 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1995-08-14 12:19:20 (GMT)
commit3050a2dc5fa8c123df98342483c9d325ab84c2bf (patch)
treeeb289b5b9ea9c66ff964ee3e2add3ef7decbbb4b /Mac/scripts
parenteaeb1c825d99514b7079bbb270053b2936323e42 (diff)
downloadcpython-3050a2dc5fa8c123df98342483c9d325ab84c2bf.zip
cpython-3050a2dc5fa8c123df98342483c9d325ab84c2bf.tar.gz
cpython-3050a2dc5fa8c123df98342483c9d325ab84c2bf.tar.bz2
Binhexify any .rsrc file in a tree
Diffstat (limited to 'Mac/scripts')
-rw-r--r--Mac/scripts/binhextree.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/Mac/scripts/binhextree.py b/Mac/scripts/binhextree.py
new file mode 100644
index 0000000..9ffefbe
--- /dev/null
+++ b/Mac/scripts/binhextree.py
@@ -0,0 +1,50 @@
+#
+# hexbintree - Recursively descend a directory and
+# pack all resource files.
+#
+# Jack Jansen, CWI, August 1995.
+#
+# To do:
+# - Also do project files (.µ and .¹), after using AppleEvents to the
+# various builders to clean the projects
+# - Don't hexbin (and clean) if there exists a .hqx file that is newer.
+#
+
+import os
+import binhex
+import sys
+
+extensions = ['.rsrc']
+
+def walker(arg, top, names):
+ for n in names:
+ for ext in extensions:
+ if n[-len(ext):] == ext:
+ name = os.path.join(top, n)
+ print 'Binhexing', name
+ binhex.binhex(name, name + '.hqx')
+
+def dodir(name):
+ os.path.walk(name, walker, None)
+
+def main():
+ if len(sys.argv) > 1:
+ for dir in sys.argv[1:]:
+ dodir(dir)
+ elif os.name == 'mac':
+ import macfs
+ dir, ok = macfs.GetDirectory('Folder to search:')
+ if not ok:
+ sys.exit(0)
+ dodir(dir.as_pathname())
+ else:
+ print 'Usage: hexbintree dir ...'
+ sys.exit(1)
+ if os.name == 'mac':
+ sys.exit(1) # Keep window
+ else:
+ sys.exit(0)
+
+if __name__ == '__main__':
+ main()
+