[Python-checkins] python/dist/src/Mac/scripts gensuitemodule.py,1.28,1.29
jackjansen@users.sourceforge.net
jackjansen@users.sourceforge.net
Thu, 06 Mar 2003 15:04:41 -0800
Update of /cvsroot/python/python/dist/src/Mac/scripts
In directory sc8-pr-cvs1:/tmp/cvs-serv25439
Modified Files:
gensuitemodule.py
Log Message:
First try to use the OSATerminology module to get the terminology
resources before reverting to manually reading the resources.
Unfortunately there is still a bug in here somewhere: it doesn't work
for all applications.
Index: gensuitemodule.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/scripts/gensuitemodule.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** gensuitemodule.py 26 Jan 2003 20:35:47 -0000 1.28
--- gensuitemodule.py 6 Mar 2003 23:04:38 -0000 1.29
***************
*** 16,24 ****
import keyword
import macresource
! from aetools import unpack
!
from Carbon.Res import *
! DEFAULT_PACKAGEFOLDER=os.path.join(sys.prefix, 'Lib', 'plat-mac', 'lib-scriptpackages')
def main():
--- 16,28 ----
import keyword
import macresource
! import aetools
! import distutils.sysconfig
! import OSATerminology
from Carbon.Res import *
+ import MacOS
! _MAC_LIB_FOLDER=os.path.dirname(aetools.__file__)
! DEFAULT_STANDARD_PACKAGEFOLDER=os.path.join(_MAC_LIB_FOLDER, 'lib-scriptpackages')
! DEFAULT_USER_PACKAGEFOLDER=distutils.sysconfig.get_python_lib()
def main():
***************
*** 27,36 ****
processfile(filename)
else:
! filename = EasyDialogs.AskFileForOpen(message='Select file with aeut/aete resource:')
if not filename:
sys.exit(0)
! processfile(filename)
! def processfile(fullname):
"""Process all resources in a single file"""
cur = CurResFile()
--- 31,48 ----
processfile(filename)
else:
! # The dialogOptionFlags below allows selection of .app bundles.
! filename = EasyDialogs.AskFileForOpen(
! message='Select scriptable application',
! dialogOptionFlags=0x1056)
if not filename:
sys.exit(0)
! try:
! processfile(filename)
! except MacOS.Error, arg:
! print "Error getting terminology:", arg
! print "Retry, manually parsing resources"
! processfile_fromresource(filename)
! def processfile_fromresource(fullname):
"""Process all resources in a single file"""
cur = CurResFile()
***************
*** 61,64 ****
--- 73,92 ----
compileaetelist(aetelist, fullname)
+ def processfile(fullname):
+ """Ask an application for its terminology and process that"""
+ aedescobj, launched = OSATerminology.GetSysTerminology(fullname)
+ if launched:
+ print "Launched", fullname
+ raw = aetools.unpack(aedescobj)
+ if not raw:
+ print 'Unpack returned empty value:', raw
+ return
+ if not raw[0].data:
+ print 'Unpack returned value without data:', raw
+ return
+ aedata = raw[0]
+ aete = decode(aedata.data)
+ compileaete(aete, None, fullname)
+
def compileaetelist(aetelist, fullname):
for aete, resinfo in aetelist:
***************
*** 241,250 ****
packagename = packagename[:27]
pathname = EasyDialogs.AskFolder(message='Create and select package folder for %s'%packagename,
! defaultLocation=DEFAULT_PACKAGEFOLDER)
if not pathname:
return
packagename = os.path.split(os.path.normpath(pathname))[1]
basepkgname = EasyDialogs.AskFolder(message='Package folder for base suite (usually StdSuites)',
! defaultLocation=DEFAULT_PACKAGEFOLDER)
if basepkgname:
dirname, basepkgname = os.path.split(os.path.normpath(basepkgname))
--- 269,278 ----
packagename = packagename[:27]
pathname = EasyDialogs.AskFolder(message='Create and select package folder for %s'%packagename,
! defaultLocation=DEFAULT_USER_PACKAGEFOLDER)
if not pathname:
return
packagename = os.path.split(os.path.normpath(pathname))[1]
basepkgname = EasyDialogs.AskFolder(message='Package folder for base suite (usually StdSuites)',
! defaultLocation=DEFAULT_STANDARD_PACKAGEFOLDER)
if basepkgname:
dirname, basepkgname = os.path.split(os.path.normpath(basepkgname))
***************
*** 908,910 ****
main()
sys.exit(1)
- print identify('for')
--- 936,937 ----