|
14 | 14 | import StringIO |
15 | 15 | import macfs |
16 | 16 | import keyword |
| 17 | +import macresource |
17 | 18 |
|
18 | 19 | from Carbon.Res import * |
19 | 20 |
|
| 21 | +DEFAULT_PACKAGEFOLDER=os.path.join(sys.prefix, 'Mac', 'Lib', 'lib-scriptpackages') |
| 22 | + |
20 | 23 | 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()) |
25 | 32 |
|
26 | 33 | def processfile(fullname): |
27 | 34 | """Process all resources in a single file""" |
28 | 35 | cur = CurResFile() |
29 | | - print fullname |
30 | | - rf = OpenRFPerm(fullname, 0, 1) |
| 36 | + print "Processing", fullname |
| 37 | + rf = macresource.open_pathname(fullname) |
31 | 38 | try: |
32 | 39 | UseResFile(rf) |
33 | 40 | resources = [] |
@@ -225,15 +232,15 @@ def compileaete(aete, resinfo, fname): |
225 | 232 | major, minor = divmod(version, 256) |
226 | 233 | fss = macfs.FSSpec(fname) |
227 | 234 | creatorsignature, dummy = fss.GetCreatorType() |
228 | | - packagename = identify(os.path.basename(fname)) |
| 235 | + packagename = identify(os.path.splitext(os.path.basename(fname))[0]) |
229 | 236 | if language: |
230 | 237 | packagename = packagename+'_lang%d'%language |
231 | 238 | if script: |
232 | 239 | packagename = packagename+'_script%d'%script |
233 | 240 | if len(packagename) > 27: |
234 | 241 | 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) |
237 | 244 | if not ok: |
238 | 245 | return |
239 | 246 | pathname = fss.as_pathname() |
@@ -288,7 +295,7 @@ def compileaete(aete, resinfo, fname): |
288 | 295 | for code, modname in suitelist[1:]: |
289 | 296 | fp.write(",\n\t\t%s_Events"%modname) |
290 | 297 | 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`) |
292 | 299 | fp.close() |
293 | 300 |
|
294 | 301 | def precompilesuite(suite, basepackage=None): |
|
0 commit comments