summaryrefslogtreecommitdiffstats
path: root/Mac/scripts
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2003-03-28 22:04:22 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2003-03-28 22:04:22 (GMT)
commit03b9c91afff90cd8ac2e0b84f486d0f2ebf4e549 (patch)
treea0e614f8057fa9f35a44b7641bbdb5b2fb71131f /Mac/scripts
parentc2a7f222164529187867bcc1a69ccde2364a91ca (diff)
downloadcpython-03b9c91afff90cd8ac2e0b84f486d0f2ebf4e549.zip
cpython-03b9c91afff90cd8ac2e0b84f486d0f2ebf4e549.tar.gz
cpython-03b9c91afff90cd8ac2e0b84f486d0f2ebf4e549.tar.bz2
- Sort various lists (list of events, OSA-classes, etc) before generating
code. This makes it a lot easier to compare the generated code for two different versions of the suite. - Various tweaks to the code to generate suites without looking at resource files manually.
Diffstat (limited to 'Mac/scripts')
-rw-r--r--Mac/scripts/gensuitemodule.py35
1 files changed, 25 insertions, 10 deletions
diff --git a/Mac/scripts/gensuitemodule.py b/Mac/scripts/gensuitemodule.py
index f22fde1..25f31ef 100644
--- a/Mac/scripts/gensuitemodule.py
+++ b/Mac/scripts/gensuitemodule.py
@@ -130,8 +130,8 @@ def processfile(fullname, output=None, basepkgname=None,
try:
aedescobj, launched = OSATerminology.GetAppTerminology(fullname)
except MacOS.Error, arg:
- if arg[0] == -1701: # errAEDescNotFound
- print "GetAppTerminology failed with errAEDescNotFound, trying manually"
+ if arg[0] in (-1701, -192): # errAEDescNotFound, resNotFound
+ print "GetAppTerminology failed with errAEDescNotFound/resNotFound, trying manually"
aedata, sig = getappterminology(fullname)
if not creatorsignature:
creatorsignature = sig
@@ -150,7 +150,7 @@ def processfile(fullname, output=None, basepkgname=None,
aedata = raw[0]
aete = decode(aedata.data)
compileaete(aete, None, fullname, output=output, basepkgname=basepkgname,
- creatorsignature=creatorsignature)
+ creatorsignature=creatorsignature, edit_modnames=edit_modnames)
def getappterminology(fullname):
"""Get application terminology by sending an AppleEvent"""
@@ -161,16 +161,24 @@ def getappterminology(fullname):
# you have created an event loop first.
import Carbon.Evt
Carbon.Evt.WaitNextEvent(0,0)
- # Now get the signature of the application, hoping it is a bundle
- pkginfo = os.path.join(fullname, 'Contents', 'PkgInfo')
- if not os.path.exists(pkginfo):
- raise RuntimeError, "No PkgInfo file found"
- tp_cr = open(pkginfo, 'rb').read()
- cr = tp_cr[4:8]
+ if os.path.isdir(fullname):
+ # Now get the signature of the application, hoping it is a bundle
+ pkginfo = os.path.join(fullname, 'Contents', 'PkgInfo')
+ if not os.path.exists(pkginfo):
+ raise RuntimeError, "No PkgInfo file found"
+ tp_cr = open(pkginfo, 'rb').read()
+ cr = tp_cr[4:8]
+ else:
+ # Assume it is a file
+ cr, tp = MacOS.GetCreatorAndType(fullname)
# Let's talk to it and ask for its AETE
talker = aetools.TalkTo(cr)
- talker._start()
+ try:
+ talker._start()
+ except (MacOS.Error, aetools.Error), arg:
+ print 'Warning: start() failed, continuing anyway:', arg
reply = talker.send("ascr", "gdte")
+ #reply2 = talker.send("ascr", "gdut")
# Now pick the bits out of the return that we need.
return reply[1]['----'], cr
@@ -406,6 +414,7 @@ def compileaete(aete, resinfo, fname, output=None, basepkgname=None,
fp.write('"""\n')
fp.write('import aetools\n')
fp.write('Error = aetools.Error\n')
+ suitelist.sort()
for code, modname in suitelist:
fp.write("import %s\n" % modname)
fp.write("\n\n_code_to_module = {\n")
@@ -433,6 +442,7 @@ def compileaete(aete, resinfo, fname, output=None, basepkgname=None,
fp.write("\t\tv._elemdict.update(getattr(v, '_privelemdict', {}))\n")
fp.write("\n")
fp.write("import StdSuites\n")
+ allprecompinfo.sort()
if allprecompinfo:
fp.write("\n#\n# Set property and element dictionaries now that all classes have been defined\n#\n")
for codenamemapper in allprecompinfo:
@@ -517,6 +527,11 @@ def compilesuite((suite, pathname, modname), major, minor, language, script,
fname, basepackage, precompinfo, interact=1):
"""Generate code for a single suite"""
[name, desc, code, level, version, events, classes, comps, enums] = suite
+ # Sort various lists, so re-generated source is easier compared
+ events.sort()
+ classes.sort()
+ comps.sort()
+ enums.sort()
fp = open(pathname, 'w')
MacOS.SetCreatorAndType(pathname, 'Pyth', 'TEXT')