File: macgen_rsrc.py

package info (click to toggle)
python2.3 2.3.5-3sarge2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 43,908 kB
  • ctags: 81,384
  • sloc: ansic: 266,250; python: 246,028; makefile: 4,194; perl: 3,702; lisp: 3,630; sh: 2,576; xml: 1,601; objc: 740; cpp: 106; sed: 2
file content (37 lines) | stat: -rw-r--r-- 1,010 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""macgen_info - Generate PYC resource file only"""
import EasyDialogs
import py_resource
from Carbon import Res
import sys

def generate(output, module_dict, debug=0, preload=1):
	fsid = py_resource.create(output)
	
	for name, module in module_dict.items():
		mtype = module.gettype()
		if mtype not in ['module', 'package']:
			continue
		location = module.__file__
		
		if location[-4:] == '.pyc':
			# Attempt corresponding .py
			location = location[:-1]
		if location[-3:] != '.py':
			print '*** skipping', location
			continue
			
		id, name = py_resource.frompyfile(location, name, preload=preload, 
				ispackage=mtype=='package')
		if debug > 0:
			print 'PYC resource %5d\t%s\t%s'%(id, name, location)
	
	Res.CloseResFile(fsid)
	
def warnings(module_dict):
	problems = 0
	for name, module in module_dict.items():
		if module.gettype() not in ('builtin', 'module', 'package'):
			problems = problems + 1
			print 'Warning: %s not included: %s %s'%(name, module.gettype(), module)
	return problems