summaryrefslogtreecommitdiffstats
path: root/Mac/Unsupported/PackLibDir.py
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2001-08-27 21:17:44 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2001-08-27 21:17:44 (GMT)
commit8f2b13efce66d1ce66060d55f26753d0e593d19f (patch)
tree0bbebe473c62673fcb94908db9674bd4743aa3f8 /Mac/Unsupported/PackLibDir.py
parentcd8a127e1a0dac4a4cd4b12bdffe8a17dd75cef9 (diff)
downloadcpython-8f2b13efce66d1ce66060d55f26753d0e593d19f.zip
cpython-8f2b13efce66d1ce66060d55f26753d0e593d19f.tar.gz
cpython-8f2b13efce66d1ce66060d55f26753d0e593d19f.tar.bz2
These have long outlived there usefulness, in my opinion. Moved to Unsupported.
Diffstat (limited to 'Mac/Unsupported/PackLibDir.py')
-rw-r--r--Mac/Unsupported/PackLibDir.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/Mac/Unsupported/PackLibDir.py b/Mac/Unsupported/PackLibDir.py
new file mode 100644
index 0000000..ba689e6
--- /dev/null
+++ b/Mac/Unsupported/PackLibDir.py
@@ -0,0 +1,49 @@
+#
+# Turn a pyc file into a resource file containing it in 'PYC ' resource form
+from Carbon.Res import *
+from Carbon import Res
+from Carbon.Resources import *
+import os
+import macfs
+import sys
+import py_resource
+
+error = 'mkpycresourcefile.error'
+
+def mkpycresourcefile(src, dst):
+ """Copy pyc file/dir src to resource file dst."""
+
+ if not os.path.isdir(src) and src[-4:] <> '.pyc':
+ raise error, 'I can only handle .pyc files or directories'
+ fsid = py_resource.create(dst)
+ if os.path.isdir(src):
+ handlesubdir(src)
+ else:
+ id, name = py_resource.frompycfile(src)
+ print 'Wrote %d: %s %s'%(id, name, src)
+ CloseResFile(fsid)
+
+def handlesubdir(srcdir):
+ """Recursively scan a directory for pyc files and copy to resources"""
+ src = os.listdir(srcdir)
+ for file in src:
+ file = os.path.join(srcdir, file)
+ if os.path.isdir(file):
+ handlesubdir(file)
+ elif file[-4:] == '.pyc':
+ id, name = py_resource.frompycfile(file)
+ print 'Wrote %d: %s %s'%(id, name, file)
+
+if __name__ == '__main__':
+ args = sys.argv[1:]
+ if not args:
+ ifss, ok = macfs.GetDirectory('Select root of tree to pack:')
+ if not ok:
+ sys.exit(0)
+ args = [ifss.as_pathname()]
+ for ifn in args:
+ ofss, ok = macfs.StandardPutFile('Output for '+os.path.split(ifn)[1])
+ if not ok:
+ sys.exit(0)
+ mkpycresourcefile(ifn, ofss.as_pathname())
+ sys.exit(1) # So we can see something...