]> granicus.if.org Git - python/commitdiff
Added an open_pathname() method which opens a resource file by pathname,
authorJack Jansen <jack.jansen@cwi.nl>
Thu, 21 Mar 2002 22:38:32 +0000 (22:38 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Thu, 21 Mar 2002 22:38:32 +0000 (22:38 +0000)
possibly converting from AppleSingle.

Mac/Lib/macresource.py

index 1cd14332a8be6944ef8da6e932093d2471f2dc2a..4bd40bcca9d90715374407c5c91e8b12943b1458 100644 (file)
@@ -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):