diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2002-03-21 22:38:32 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2002-03-21 22:38:32 (GMT) |
commit | 562baabb61d1ecdeddf8b1df5ece1ea3400d7f0d (patch) | |
tree | 5a52630bbf97ab03896b6d0c63bb8b36ceb62874 /Mac/Lib | |
parent | b9e66612069f0f1ce9f38c4abb7f273289efd203 (diff) | |
download | cpython-562baabb61d1ecdeddf8b1df5ece1ea3400d7f0d.zip cpython-562baabb61d1ecdeddf8b1df5ece1ea3400d7f0d.tar.gz cpython-562baabb61d1ecdeddf8b1df5ece1ea3400d7f0d.tar.bz2 |
Added an open_pathname() method which opens a resource file by pathname,
possibly converting from AppleSingle.
Diffstat (limited to 'Mac/Lib')
-rw-r--r-- | Mac/Lib/macresource.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/Mac/Lib/macresource.py b/Mac/Lib/macresource.py index 1cd1433..4bd40bc 100644 --- a/Mac/Lib/macresource.py +++ b/Mac/Lib/macresource.py @@ -61,6 +61,18 @@ def need(restype, resid, filename=None, modname=None): else: raise ResourceFileNotFoundError, filename + refno = open_pathname(pathname) + + # 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 + +def open_pathname(pathname): + """Open a resource file given by pathname, possibly decoding an + AppleSingle file""" try: refno = Res.FSpOpenResFile(pathname, 1) except Res.Error, arg: @@ -72,13 +84,6 @@ def need(restype, resid, filename=None, modname=None): refno = Res.FSOpenResourceFile(pathname, u'', 1) else: raise - - - # 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 def _decode(pathname): |