summaryrefslogtreecommitdiffstats
path: root/Mac/Lib
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2001-08-27 21:37:45 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2001-08-27 21:37:45 (GMT)
commita5d7da528bda145426c50ad9ded8d0707d5f302c (patch)
tree7fee2c970ecf6e3e2d7ad46cceae933315edcbcd /Mac/Lib
parentde3226f7f9cda4e6bb4c871c39b9bb2a3c00534a (diff)
downloadcpython-a5d7da528bda145426c50ad9ded8d0707d5f302c.zip
cpython-a5d7da528bda145426c50ad9ded8d0707d5f302c.tar.gz
cpython-a5d7da528bda145426c50ad9ded8d0707d5f302c.tar.bz2
need() now returns the refno of the resource file opened, or None if the
specified resource was already available and no file was opened.
Diffstat (limited to 'Mac/Lib')
-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 1aabe12..9b442a8 100644
--- a/Mac/Lib/macresource.py
+++ b/Mac/Lib/macresource.py
@@ -12,7 +12,9 @@ def need(restype, resid, filename=None, modname=None):
are required parameters, and identify the resource for which to test. If it
is available we are done. If it is not available we look for a file filename
(default: modname with .rsrc appended) either in the same folder as
- where modname was loaded from, or otherwise across sys.path."""
+ where modname was loaded from, or otherwise across sys.path.
+
+ Returns the refno of the resource file opened (or None)"""
if modname is None and filename is None:
raise ArgumentError, "Either filename or modname argument (or both) must be given"
@@ -23,14 +25,14 @@ def need(restype, resid, filename=None, modname=None):
except Res.Error:
pass
else:
- return
+ return None
else:
try:
h = Res.GetNamedResource(restype, resid)
except Res.Error:
pass
else:
- return
+ return None
# Construct a filename if we don't have one
if not filename:
@@ -59,10 +61,11 @@ def need(restype, resid, filename=None, modname=None):
else:
raise ResourceFileNotFoundError, filename
- Res.FSpOpenResFile(pathname, 1)
+ refno = Res.FSpOpenResFile(pathname, 1)
# And check that the resource exists now
if type(resid) is type(1):
h = Res.GetResource(restype, resid)
else:
h = Res.GetNamedResource(restype, resid)
+ return refno \ No newline at end of file