[Python-checkins] CVS: python/dist/src/Mac/Lib macresource.py,1.3,1.4

Jack Jansen jackjansen@users.sourceforge.net
Sun, 13 Jan 2002 15:18:02 -0800


Update of /cvsroot/python/python/dist/src/Mac/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv17562

Modified Files:
	macresource.py 
Log Message:
Fixed to work under MachoPython, doing the expected unpacking for applesingle files. The IDE still doesn't work, though, because it uses :-style pathnames.


Index: macresource.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Lib/macresource.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** macresource.py	2001/08/30 21:19:42	1.3
--- macresource.py	2002/01/13 23:18:00	1.4
***************
*** 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