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

Function convertdir

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

Source from the content-addressed store, hash-verified

370 marshal.dump(d,f)
371
372def 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
400def rewritepythondir(dir, dirprefix='', comments=1):
401

Callers 1

gencodec.pyFile · 0.85

Calls 9

readmapFunction · 0.85
pymapFunction · 0.85
marshalmapFunction · 0.85
listdirMethod · 0.80
joinMethod · 0.45
isfileMethod · 0.45
splitMethod · 0.45
replaceMethod · 0.45
lowerMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…