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

Jack Jansen jackjansen@users.sourceforge.net
Fri, 29 Mar 2002 06:29:37 -0800


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

Modified Files:
	macresource.py 
Log Message:
If the file has no resource fork first check to see whether it's a
datafork-based resource file before trying to decode it as AppleSingle.


Index: macresource.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Lib/macresource.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** macresource.py	21 Mar 2002 22:38:32 -0000	1.5
--- macresource.py	29 Mar 2002 14:29:35 -0000	1.6
***************
*** 78,88 ****
  	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
  	return refno
  	
--- 78,95 ----
  	except Res.Error, arg:
  		if arg[0] in (-37, -39):
! 			# No resource fork. We may be on OSX, and this may be either
! 			# a data-fork based resource file or a AppleSingle file
! 			# from the CVS repository.
! 			try:
  				refno = Res.FSOpenResourceFile(pathname, u'', 1)
+ 			except Res.Error, arg:
+ 				if arg[0] != -199:
+ 					# -199 is "bad resource map"
+ 					raise
  			else:
! 				return refno
! 			# Finally try decoding an AppleSingle file
! 			pathname = _decode(pathname)
! 			refno = Res.FSOpenResourceFile(pathname, u'', 1)
  	return refno