From 4092606d6bad63f15009d8a2b2b6d37e62e74cc8 Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Sat, 30 Mar 2002 23:43:04 +0000 Subject: [PATCH] Modified to allow it to run in MachoPython in a reasonable way. It still needs a decent commandline interface, though. --- Mac/scripts/gensuitemodule.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Mac/scripts/gensuitemodule.py b/Mac/scripts/gensuitemodule.py index 5a4c806ab18..4f2ddc0d741 100644 --- a/Mac/scripts/gensuitemodule.py +++ b/Mac/scripts/gensuitemodule.py @@ -14,20 +14,27 @@ import types import StringIO import macfs import keyword +import macresource from Carbon.Res import * +DEFAULT_PACKAGEFOLDER=os.path.join(sys.prefix, 'Mac', 'Lib', 'lib-scriptpackages') + def main(): - fss, ok = macfs.PromptGetFile('Select file with aeut/aete resource:') - if not ok: - sys.exit(0) - processfile(fss.as_pathname()) + if len(sys.argv) > 1: + for filename in sys.argv[1:]: + processfile(filename) + else: + fss, ok = macfs.PromptGetFile('Select file with aeut/aete resource:') + if not ok: + sys.exit(0) + processfile(fss.as_pathname()) def processfile(fullname): """Process all resources in a single file""" cur = CurResFile() - print fullname - rf = OpenRFPerm(fullname, 0, 1) + print "Processing", fullname + rf = macresource.open_pathname(fullname) try: UseResFile(rf) resources = [] @@ -225,15 +232,15 @@ def compileaete(aete, resinfo, fname): major, minor = divmod(version, 256) fss = macfs.FSSpec(fname) creatorsignature, dummy = fss.GetCreatorType() - packagename = identify(os.path.basename(fname)) + packagename = identify(os.path.splitext(os.path.basename(fname))[0]) if language: packagename = packagename+'_lang%d'%language if script: packagename = packagename+'_script%d'%script if len(packagename) > 27: packagename = packagename[:27] - macfs.SetFolder(os.path.join(sys.prefix, ':Mac:Lib:lib-scriptpackages')) - fss, ok = macfs.GetDirectory('Package folder for %s'%packagename) + macfs.SetFolder(DEFAULT_PACKAGEFOLDER) + fss, ok = macfs.GetDirectory('Create and select package folder for %s'%packagename) if not ok: return pathname = fss.as_pathname() @@ -288,7 +295,7 @@ def compileaete(aete, resinfo, fname): for code, modname in suitelist[1:]: fp.write(",\n\t\t%s_Events"%modname) fp.write(",\n\t\taetools.TalkTo):\n") - fp.write("\t_signature = '%s'\n\n"%creatorsignature) + fp.write("\t_signature = %s\n\n"%`creatorsignature`) fp.close() def precompilesuite(suite, basepackage=None):