@@ -130,8 +130,8 @@ def processfile(fullname, output=None, basepkgname=None,
130130 try :
131131 aedescobj , launched = OSATerminology .GetAppTerminology (fullname )
132132 except MacOS .Error , arg :
133- if arg [0 ] == - 1701 : # errAEDescNotFound
134- print "GetAppTerminology failed with errAEDescNotFound, trying manually"
133+ if arg [0 ] in ( - 1701 , - 192 ) : # errAEDescNotFound, resNotFound
134+ print "GetAppTerminology failed with errAEDescNotFound/resNotFound , trying manually"
135135 aedata , sig = getappterminology (fullname )
136136 if not creatorsignature :
137137 creatorsignature = sig
@@ -150,7 +150,7 @@ def processfile(fullname, output=None, basepkgname=None,
150150 aedata = raw [0 ]
151151 aete = decode (aedata .data )
152152 compileaete (aete , None , fullname , output = output , basepkgname = basepkgname ,
153- creatorsignature = creatorsignature )
153+ creatorsignature = creatorsignature , edit_modnames = edit_modnames )
154154
155155def getappterminology (fullname ):
156156 """Get application terminology by sending an AppleEvent"""
@@ -161,16 +161,24 @@ def getappterminology(fullname):
161161 # you have created an event loop first.
162162 import Carbon .Evt
163163 Carbon .Evt .WaitNextEvent (0 ,0 )
164- # Now get the signature of the application, hoping it is a bundle
165- pkginfo = os .path .join (fullname , 'Contents' , 'PkgInfo' )
166- if not os .path .exists (pkginfo ):
167- raise RuntimeError , "No PkgInfo file found"
168- tp_cr = open (pkginfo , 'rb' ).read ()
169- cr = tp_cr [4 :8 ]
164+ if os .path .isdir (fullname ):
165+ # Now get the signature of the application, hoping it is a bundle
166+ pkginfo = os .path .join (fullname , 'Contents' , 'PkgInfo' )
167+ if not os .path .exists (pkginfo ):
168+ raise RuntimeError , "No PkgInfo file found"
169+ tp_cr = open (pkginfo , 'rb' ).read ()
170+ cr = tp_cr [4 :8 ]
171+ else :
172+ # Assume it is a file
173+ cr , tp = MacOS .GetCreatorAndType (fullname )
170174 # Let's talk to it and ask for its AETE
171175 talker = aetools .TalkTo (cr )
172- talker ._start ()
176+ try :
177+ talker ._start ()
178+ except (MacOS .Error , aetools .Error ), arg :
179+ print 'Warning: start() failed, continuing anyway:' , arg
173180 reply = talker .send ("ascr" , "gdte" )
181+ #reply2 = talker.send("ascr", "gdut")
174182 # Now pick the bits out of the return that we need.
175183 return reply [1 ]['----' ], cr
176184
@@ -406,6 +414,7 @@ def compileaete(aete, resinfo, fname, output=None, basepkgname=None,
406414 fp .write ('"""\n ' )
407415 fp .write ('import aetools\n ' )
408416 fp .write ('Error = aetools.Error\n ' )
417+ suitelist .sort ()
409418 for code , modname in suitelist :
410419 fp .write ("import %s\n " % modname )
411420 fp .write ("\n \n _code_to_module = {\n " )
@@ -433,6 +442,7 @@ def compileaete(aete, resinfo, fname, output=None, basepkgname=None,
433442 fp .write ("\t \t v._elemdict.update(getattr(v, '_privelemdict', {}))\n " )
434443 fp .write ("\n " )
435444 fp .write ("import StdSuites\n " )
445+ allprecompinfo .sort ()
436446 if allprecompinfo :
437447 fp .write ("\n #\n # Set property and element dictionaries now that all classes have been defined\n #\n " )
438448 for codenamemapper in allprecompinfo :
@@ -517,6 +527,11 @@ def compilesuite((suite, pathname, modname), major, minor, language, script,
517527 fname , basepackage , precompinfo , interact = 1 ):
518528 """Generate code for a single suite"""
519529 [name , desc , code , level , version , events , classes , comps , enums ] = suite
530+ # Sort various lists, so re-generated source is easier compared
531+ events .sort ()
532+ classes .sort ()
533+ comps .sort ()
534+ enums .sort ()
520535
521536 fp = open (pathname , 'w' )
522537 MacOS .SetCreatorAndType (pathname , 'Pyth' , 'TEXT' )
0 commit comments