summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2002-08-09 13:42:55 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2002-08-09 13:42:55 (GMT)
commitb8da8d7761b0755c602a965d0fb7f52c7c4c47fa (patch)
tree9d8e9fa82d54790b17997f3d51c54e1d86f124dd /Mac
parentb6434f2c2ff94abfe2d639eff20d3d5ba1b0fd7a (diff)
downloadcpython-b8da8d7761b0755c602a965d0fb7f52c7c4c47fa.zip
cpython-b8da8d7761b0755c602a965d0fb7f52c7c4c47fa.tar.gz
cpython-b8da8d7761b0755c602a965d0fb7f52c7c4c47fa.tar.bz2
Tool to pre-created cached .rsrc.df.rsrc files in the Lib directories,
similar to compileall.py.
Diffstat (limited to 'Mac')
-rw-r--r--Mac/scripts/cachersrc.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/Mac/scripts/cachersrc.py b/Mac/scripts/cachersrc.py
new file mode 100644
index 0000000..e6524c9
--- /dev/null
+++ b/Mac/scripts/cachersrc.py
@@ -0,0 +1,45 @@
+# Scan the tree passed as argv[0] for .rsrc files, skipping .rsrc.df.rsrc
+# files, and open these. The effect of this is to create the .rsrc.df.rsrc
+# cache files if needed.
+# These are needed on OSX: the .rsrc files are in reality AppleSingle-encoded
+# files. We decode the resources into a datafork-based resource file.
+
+import macresource
+import os
+import sys
+import getopt
+
+class NoArgsError(Exception):
+ pass
+
+def handler((verbose, force), dirname, fnames):
+ for fn in fnames:
+ if fn[-5:] == '.rsrc' and fn[-13:] != '.rsrc.df.rsrc':
+ if force:
+ try:
+ os.unlink(os.path.join(dirname, fn + '.df.rsrc'))
+ except IOError:
+ pass
+ macresource.open_pathname(os.path.join(dirname, fn), verbose=verbose)
+
+def main():
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], 'vf')
+ if not args:
+ raise NoArgsError
+ except (getopt.GetoptError, NoArgsError):
+ sys.stderr.write('Usage: cachersrc.py dirname ...\n')
+ sys.exit(1)
+ verbose = 0
+ force = 0
+ for o, v in opts:
+ if o == '-v':
+ verbose = 1
+ if o == '-f':
+ force = 1
+ for dir in sys.argv[1:]:
+ os.path.walk(dir, handler, (verbose, force))
+
+if __name__ == '__main__':
+ main()
+ \ No newline at end of file