summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2002-08-09 13:44:03 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2002-08-09 13:44:03 (GMT)
commitccd8e8d7419c5ac8a646fcecaf4b168b9341c147 (patch)
tree5c1b1783371021375e14762fd3da7cb0a3bf75d6 /Mac
parentb8da8d7761b0755c602a965d0fb7f52c7c4c47fa (diff)
downloadcpython-ccd8e8d7419c5ac8a646fcecaf4b168b9341c147.zip
cpython-ccd8e8d7419c5ac8a646fcecaf4b168b9341c147.tar.gz
cpython-ccd8e8d7419c5ac8a646fcecaf4b168b9341c147.tar.bz2
- Check not only that cache file exists, but also that it is newer than
the applesingle file. - Added optional verbose option for cachersrc tool.
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Lib/macresource.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/Mac/Lib/macresource.py b/Mac/Lib/macresource.py
index 23713a5..3a1161b 100644
--- a/Mac/Lib/macresource.py
+++ b/Mac/Lib/macresource.py
@@ -70,7 +70,7 @@ def need(restype, resid, filename=None, modname=None):
h = Res.GetNamedResource(restype, resid)
return refno
-def open_pathname(pathname):
+def open_pathname(pathname, verbose=0):
"""Open a resource file given by pathname, possibly decoding an
AppleSingle file"""
try:
@@ -89,17 +89,20 @@ def open_pathname(pathname):
else:
return refno
# Finally try decoding an AppleSingle file
- pathname = _decode(pathname)
+ pathname = _decode(pathname, verbose=verbose)
refno = Res.FSOpenResourceFile(pathname, u'', 1)
else:
raise
return refno
-def _decode(pathname):
+def _decode(pathname, verbose=0):
# Decode an AppleSingle resource file, return the new pathname.
newpathname = pathname + '.df.rsrc'
- if os.path.exists(newpathname):
+ if os.path.exists(newpathname) and \
+ os.stat(newpathname).st_mtime >= os.stat(pathname).st_mtime:
return newpathname
+ if verbose:
+ print 'Decoding', pathname
import applesingle
applesingle.decode(pathname, newpathname, resonly=1)
return newpathname