Jack Jansen | 11493bc | 2001-05-22 22:18:21 +0000 | [diff] [blame] | 1 | # bgenall - Generate all bgen-generated modules |
| 2 | # |
| 3 | import sys |
| 4 | import os |
| 5 | import string |
| 6 | |
| 7 | def bgenone(dirname, shortname): |
| 8 | os.chdir(dirname) |
Jack Jansen | 1b8bd94 | 2001-12-14 23:01:34 +0000 | [diff] [blame] | 9 | try: |
| 10 | m = __import__(shortname+'scan') |
| 11 | except: |
| 12 | return 0 |
Jack Jansen | 11493bc | 2001-05-22 22:18:21 +0000 | [diff] [blame] | 13 | try: |
| 14 | m.main() |
| 15 | except: |
| 16 | return 0 |
| 17 | return 1 |
| 18 | |
| 19 | def main(): |
| 20 | success = [] |
| 21 | failure = [] |
| 22 | sys.path.insert(0, ':') |
| 23 | srcdir = os.path.join(os.path.join(sys.prefix, 'Mac'), 'Modules') |
| 24 | contents = os.listdir(srcdir) |
| 25 | for name in contents: |
| 26 | moduledir = os.path.join(srcdir, name) |
| 27 | scanmodule = os.path.join(moduledir, name +'scan.py') |
| 28 | if os.path.exists(scanmodule): |
| 29 | if bgenone(moduledir, name): |
| 30 | success.append(name) |
| 31 | else: |
| 32 | failure.append(name) |
| 33 | print 'Done:', string.join(success, ' ') |
| 34 | if failure: |
| 35 | print 'Failed:', string.join(failure, ' ') |
| 36 | return 0 |
| 37 | return 1 |
| 38 | |
| 39 | if __name__ == '__main__': |
| 40 | rv = main() |
| 41 | sys.exit(not rv) |