Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4092606

Browse files
committed
Modified to allow it to run in MachoPython in a reasonable way. It still
needs a decent commandline interface, though.
1 parent c2ce91a commit 4092606

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

Mac/scripts/gensuitemodule.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,27 @@
1414
import StringIO
1515
import macfs
1616
import keyword
17+
import macresource
1718

1819
from Carbon.Res import *
1920

21+
DEFAULT_PACKAGEFOLDER=os.path.join(sys.prefix, 'Mac', 'Lib', 'lib-scriptpackages')
22+
2023
def main():
21-
fss, ok = macfs.PromptGetFile('Select file with aeut/aete resource:')
22-
if not ok:
23-
sys.exit(0)
24-
processfile(fss.as_pathname())
24+
if len(sys.argv) > 1:
25+
for filename in sys.argv[1:]:
26+
processfile(filename)
27+
else:
28+
fss, ok = macfs.PromptGetFile('Select file with aeut/aete resource:')
29+
if not ok:
30+
sys.exit(0)
31+
processfile(fss.as_pathname())
2532

2633
def processfile(fullname):
2734
"""Process all resources in a single file"""
2835
cur = CurResFile()
29-
print fullname
30-
rf = OpenRFPerm(fullname, 0, 1)
36+
print "Processing", fullname
37+
rf = macresource.open_pathname(fullname)
3138
try:
3239
UseResFile(rf)
3340
resources = []
@@ -225,15 +232,15 @@ def compileaete(aete, resinfo, fname):
225232
major, minor = divmod(version, 256)
226233
fss = macfs.FSSpec(fname)
227234
creatorsignature, dummy = fss.GetCreatorType()
228-
packagename = identify(os.path.basename(fname))
235+
packagename = identify(os.path.splitext(os.path.basename(fname))[0])
229236
if language:
230237
packagename = packagename+'_lang%d'%language
231238
if script:
232239
packagename = packagename+'_script%d'%script
233240
if len(packagename) > 27:
234241
packagename = packagename[:27]
235-
macfs.SetFolder(os.path.join(sys.prefix, ':Mac:Lib:lib-scriptpackages'))
236-
fss, ok = macfs.GetDirectory('Package folder for %s'%packagename)
242+
macfs.SetFolder(DEFAULT_PACKAGEFOLDER)
243+
fss, ok = macfs.GetDirectory('Create and select package folder for %s'%packagename)
237244
if not ok:
238245
return
239246
pathname = fss.as_pathname()
@@ -288,7 +295,7 @@ def compileaete(aete, resinfo, fname):
288295
for code, modname in suitelist[1:]:
289296
fp.write(",\n\t\t%s_Events"%modname)
290297
fp.write(",\n\t\taetools.TalkTo):\n")
291-
fp.write("\t_signature = '%s'\n\n"%creatorsignature)
298+
fp.write("\t_signature = %s\n\n"%`creatorsignature`)
292299
fp.close()
293300

294301
def precompilesuite(suite, basepackage=None):

0 commit comments

Comments
 (0)