(dir, dirprefix='', nameprefix='', comments=1)
| 370 | marshal.dump(d,f) |
| 371 | |
| 372 | def convertdir(dir, dirprefix='', nameprefix='', comments=1): |
| 373 | |
| 374 | mapnames = os.listdir(dir) |
| 375 | for mapname in mapnames: |
| 376 | mappathname = os.path.join(dir, mapname) |
| 377 | if not os.path.isfile(mappathname): |
| 378 | continue |
| 379 | name = os.path.split(mapname)[1] |
| 380 | name = name.replace('-','_') |
| 381 | name = name.split('.')[0] |
| 382 | name = name.lower() |
| 383 | name = nameprefix + name |
| 384 | codefile = name + '.py' |
| 385 | marshalfile = name + '.mapping' |
| 386 | print('converting %s to %s and %s' % (mapname, |
| 387 | dirprefix + codefile, |
| 388 | dirprefix + marshalfile)) |
| 389 | try: |
| 390 | map = readmap(os.path.join(dir,mapname)) |
| 391 | if not map: |
| 392 | print('* map is empty; skipping') |
| 393 | else: |
| 394 | pymap(mappathname, map, dirprefix + codefile,name,comments) |
| 395 | marshalmap(mappathname, map, dirprefix + marshalfile) |
| 396 | except ValueError as why: |
| 397 | print('* conversion failed: %s' % why) |
| 398 | raise |
| 399 | |
| 400 | def rewritepythondir(dir, dirprefix='', comments=1): |
| 401 |
no test coverage detected
searching dependent graphs…