Modified to allow it to run in MachoPython in a reasonable way. It still

needs a decent commandline interface, though.
This commit is contained in:
Jack Jansen 2002-03-30 23:43:04 +00:00
parent c2ce91af5f
commit 4092606d6b
1 changed files with 17 additions and 10 deletions

View File

@ -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):