mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Added an open_pathname() method which opens a resource file by pathname,
possibly converting from AppleSingle.
This commit is contained in:
		
							parent
							
								
									b9e6661206
								
							
						
					
					
						commit
						562baabb61
					
				
					 1 changed files with 12 additions and 7 deletions
				
			
		|  | @ -61,6 +61,18 @@ def need(restype, resid, filename=None, modname=None): | ||||||
| 	else: | 	else: | ||||||
| 		raise ResourceFileNotFoundError, filename | 		raise ResourceFileNotFoundError, filename | ||||||
| 	 | 	 | ||||||
|  | 	refno = open_pathname(pathname) | ||||||
|  | 	 | ||||||
|  | 	# And check that the resource exists now | ||||||
|  | 	if type(resid) is type(1): | ||||||
|  | 		h = Res.GetResource(restype, resid) | ||||||
|  | 	else: | ||||||
|  | 		h = Res.GetNamedResource(restype, resid) | ||||||
|  | 	return refno | ||||||
|  | 	 | ||||||
|  | def open_pathname(pathname): | ||||||
|  | 	"""Open a resource file given by pathname, possibly decoding an | ||||||
|  | 	AppleSingle file""" | ||||||
| 	try: | 	try: | ||||||
| 		refno = Res.FSpOpenResFile(pathname, 1) | 		refno = Res.FSpOpenResFile(pathname, 1) | ||||||
| 	except Res.Error, arg: | 	except Res.Error, arg: | ||||||
|  | @ -72,13 +84,6 @@ def need(restype, resid, filename=None, modname=None): | ||||||
| 				refno = Res.FSOpenResourceFile(pathname, u'', 1) | 				refno = Res.FSOpenResourceFile(pathname, u'', 1) | ||||||
| 			else: | 			else: | ||||||
| 				raise | 				raise | ||||||
| 				 |  | ||||||
| 	 |  | ||||||
| 	# And check that the resource exists now |  | ||||||
| 	if type(resid) is type(1): |  | ||||||
| 		h = Res.GetResource(restype, resid) |  | ||||||
| 	else: |  | ||||||
| 		h = Res.GetNamedResource(restype, resid) |  | ||||||
| 	return refno | 	return refno | ||||||
| 	 | 	 | ||||||
| def _decode(pathname): | def _decode(pathname): | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Jack Jansen
						Jack Jansen