[Python-checkins] python/dist/src/Mac/Lib macresource.py,1.7,1.8

jackjansen@users.sourceforge.net jackjansen@users.sourceforge.net
Fri, 09 Aug 2002 06:44:09 -0700


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

Modified Files:
	macresource.py 
Log Message:
- Check not only that cache file exists, but also that it is newer than
  the applesingle file.
- Added optional verbose option for cachersrc tool.


Index: macresource.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Lib/macresource.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** macresource.py	29 Mar 2002 21:17:57 -0000	1.7
--- macresource.py	9 Aug 2002 13:44:03 -0000	1.8
***************
*** 71,75 ****
  	return refno
  	
! def open_pathname(pathname):
  	"""Open a resource file given by pathname, possibly decoding an
  	AppleSingle file"""
--- 71,75 ----
  	return refno
  	
! def open_pathname(pathname, verbose=0):
  	"""Open a resource file given by pathname, possibly decoding an
  	AppleSingle file"""
***************
*** 90,94 ****
  				return refno
  			# Finally try decoding an AppleSingle file
! 			pathname = _decode(pathname)
  			refno = Res.FSOpenResourceFile(pathname, u'', 1)
  		else:
--- 90,94 ----
  				return refno
  			# Finally try decoding an AppleSingle file
! 			pathname = _decode(pathname, verbose=verbose)
  			refno = Res.FSOpenResourceFile(pathname, u'', 1)
  		else:
***************
*** 96,104 ****
  	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)
--- 96,107 ----
  	return refno
  	
! def _decode(pathname, verbose=0):
  	# Decode an AppleSingle resource file, return the new pathname.
  	newpathname = pathname + '.df.rsrc'
! 	if os.path.exists(newpathname) and \
! 			os.stat(newpathname).st_mtime >= os.stat(pathname).st_mtime:
  		return newpathname
+ 	if verbose:
+ 		print 'Decoding', pathname
  	import applesingle
  	applesingle.decode(pathname, newpathname, resonly=1)