1998-06-26 14:56:00 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								"""macgen_info - Generate PYC resource file only"""
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import EasyDialogs
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import py_resource
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import Res
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import sys
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def generate(output, module_dict, debug=0, preload=1):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									fsid = py_resource.create(output)
							 | 
						
					
						
							
								
									
										
										
										
											1998-08-18 12:23:11 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									
							 | 
						
					
						
							
								
									
										
										
										
											1998-06-26 14:56:00 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									for name, module in module_dict.items():
							 | 
						
					
						
							
								
									
										
										
										
											1998-08-18 12:23:11 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										mtype = module.gettype()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if mtype not in ['module', 'package']:
							 | 
						
					
						
							
								
									
										
										
										
											1998-06-26 14:56:00 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
											continue
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										location = module.__file__
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if location[-4:] == '.pyc':
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											# Attempt corresponding .py
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											location = location[:-1]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if location[-3:] != '.py':
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											print '*** skipping', location
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											continue
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											
							 | 
						
					
						
							
								
									
										
										
										
											1998-08-18 12:23:11 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										id, name = py_resource.frompyfile(location, name, preload=preload, 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												ispackage=mtype=='package')
							 | 
						
					
						
							
								
									
										
										
										
											1998-06-26 14:56:00 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if debug > 0:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											print 'PYC resource %5d\t%s\t%s'%(id, name, location)
							 | 
						
					
						
							
								
									
										
										
										
											1998-08-18 12:23:11 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									
							 | 
						
					
						
							
								
									
										
										
										
											1998-06-26 14:56:00 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Res.CloseResFile(fsid)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def warnings(module_dict):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									problems = 0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									for name, module in module_dict.items():
							 | 
						
					
						
							
								
									
										
										
										
											1999-01-21 12:49:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if module.gettype() not in ('builtin', 'module', 'package'):
							 | 
						
					
						
							
								
									
										
										
										
											1998-06-26 14:56:00 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
											problems = problems + 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											print 'Warning: %s not included: %s %s'%(name, module.gettype(), module)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									return problems
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									
							 |