MCPcopy Index your code
hub / github.com/python/cpython / rewritepythondir

Function rewritepythondir

Tools/unicode/gencodec.py:400–418  ·  view source on GitHub ↗
(dir, dirprefix='', comments=1)

Source from the content-addressed store, hash-verified

398 raise
399
400def 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
420if __name__ == '__main__':
421

Callers 1

gencodec.pyFile · 0.85

Calls 6

pymapFunction · 0.85
listdirMethod · 0.80
openFunction · 0.50
endswithMethod · 0.45
joinMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…