[Python-checkins] CVS: python/dist/src/Mac/Lib macresource.py,1.3,1.3.14.1
Jack Jansen
jackjansen@users.sourceforge.net
Sun, 24 Feb 2002 14:51:28 -0800
Update of /cvsroot/python/python/dist/src/Mac/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv18830
Modified Files:
Tag: release22-maint
macresource.py
Log Message:
backport of 1.13:
Fixed to work under MachoPython, doing the expected unpacking for applesingle
files.
Index: macresource.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Lib/macresource.py,v
retrieving revision 1.3
retrieving revision 1.3.14.1
diff -C2 -d -r1.3 -r1.3.14.1
*** macresource.py 30 Aug 2001 21:19:42 -0000 1.3
--- macresource.py 24 Feb 2002 22:51:26 -0000 1.3.14.1
***************
*** 62,66 ****
raise ResourceFileNotFoundError, filename
! refno = Res.FSpOpenResFile(pathname, 1)
# And check that the resource exists now
--- 62,77 ----
raise ResourceFileNotFoundError, filename
! 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
***************
*** 69,71 ****
else:
h = Res.GetNamedResource(restype, resid)
! return refno
\ No newline at end of file
--- 80,93 ----
else:
h = Res.GetNamedResource(restype, resid)
! 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
!
!
\ No newline at end of file