Fixed to work under MachoPython, doing the expected unpacking for applesingle files. The IDE still doesn't work, though, because it uses :-style pathnames.
This commit is contained in:
parent
d48b10621e
commit
32d1a3b1c9
|
@ -61,11 +61,33 @@ def need(restype, resid, filename=None, modname=None):
|
||||||
else:
|
else:
|
||||||
raise ResourceFileNotFoundError, filename
|
raise ResourceFileNotFoundError, filename
|
||||||
|
|
||||||
refno = Res.FSpOpenResFile(pathname, 1)
|
try:
|
||||||
|
refno = Res.FSpOpenResFile(pathname, 1)
|
||||||
|
except Res.Error, arg:
|
||||||
|
if arg[0] in (-37, -39):
|
||||||
|
# No resource fork. We may be on OSX, try to decode
|
||||||
|
# the applesingle file.
|
||||||
|
pathname = _decode(pathname)
|
||||||
|
if pathname:
|
||||||
|
refno = Res.FSOpenResourceFile(pathname, u'', 1)
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
# And check that the resource exists now
|
# And check that the resource exists now
|
||||||
if type(resid) is type(1):
|
if type(resid) is type(1):
|
||||||
h = Res.GetResource(restype, resid)
|
h = Res.GetResource(restype, resid)
|
||||||
else:
|
else:
|
||||||
h = Res.GetNamedResource(restype, resid)
|
h = Res.GetNamedResource(restype, resid)
|
||||||
return refno
|
return refno
|
||||||
|
|
||||||
|
def _decode(pathname):
|
||||||
|
# Decode an AppleSingle resource file, return the new pathname.
|
||||||
|
newpathname = pathname + '.df.rsrc'
|
||||||
|
if os.path.exists(newpathname):
|
||||||
|
return newpathname
|
||||||
|
import applesingle
|
||||||
|
applesingle.decode(pathname, newpathname, resonly=1)
|
||||||
|
return newpathname
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue