Jack Jansen | 5220d02 | 1996-07-10 13:19:08 +0000 | [diff] [blame] | 1 | # |
| 2 | # Given a module-list generated by findmodulefiles |
| 3 | # generate the resource file with all needed modules |
| 4 | # |
| 5 | import macfs |
| 6 | import py_resource |
| 7 | import Res |
| 8 | import sys |
| 9 | |
| 10 | def main(): |
| 11 | fss, ok = macfs.PromptGetFile('Module sources listing:', 'TEXT') |
| 12 | if not ok: |
| 13 | sys.exit(0) |
| 14 | ofss, ok = macfs.StandardPutFile('PYC resource output file:') |
| 15 | if not ok: |
| 16 | sys.exit(0) |
| 17 | mfss, ok = macfs.PromptGetFile('Source for __main__ (or cancel):') |
| 18 | if ok: |
| 19 | mainfile = mfss.as_pathname() |
| 20 | else: |
| 21 | mainfile = None |
| 22 | fp = open(fss.as_pathname()) |
| 23 | data = fp.read() |
| 24 | modules = eval(data) |
| 25 | |
| 26 | fsid = py_resource.create(ofss.as_pathname(), creator='RSED') |
| 27 | |
| 28 | if mainfile: |
| 29 | id, name = py_resource.frompyfile(mainfile, '__main__') |
| 30 | for module, source in modules: |
| 31 | if source: |
| 32 | id, name = py_resource.frompyfile(source) |
| 33 | print 'Wrote %d %s: %s'%(id, name, source) |
| 34 | |
| 35 | Res.CloseResFile(fsid) |
| 36 | |
| 37 | if __name__ == '__main__': |
| 38 | main() |
| 39 | sys.exit(1) |