]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Binhexify any .rsrc file in a tree
authorJack Jansen <jack.jansen@cwi.nl>
Mon, 14 Aug 1995 12:19:20 +0000 (12:19 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Mon, 14 Aug 1995 12:19:20 +0000 (12:19 +0000)
Mac/scripts/binhextree.py [new file with mode: 0644]

diff --git a/Mac/scripts/binhextree.py b/Mac/scripts/binhextree.py
new file mode 100644 (file)
index 0000000..9ffefbe
--- /dev/null
@@ -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()
+