| 398 | raise |
| 399 | |
| 400 | def rewritepythondir(dir, dirprefix='', comments=1): |
| 401 | |
| 402 | mapnames = os.listdir(dir) |
| 403 | for mapname in mapnames: |
| 404 | if not mapname.endswith('.mapping'): |
| 405 | continue |
| 406 | name = mapname[:-len('.mapping')] |
| 407 | codefile = name + '.py' |
| 408 | print('converting %s to %s' % (mapname, |
| 409 | dirprefix + codefile)) |
| 410 | try: |
| 411 | with open(os.path.join(dir, mapname), 'rb') as f: |
| 412 | map = marshal.load(f) |
| 413 | if not map: |
| 414 | print('* map is empty; skipping') |
| 415 | else: |
| 416 | pymap(mapname, map, dirprefix + codefile,name,comments) |
| 417 | except ValueError as why: |
| 418 | print('* conversion failed: %s' % why) |
| 419 | |
| 420 | if __name__ == '__main__': |
| 421 | |