code: def rewritepythondir(dir, dirprefix="", comments=1):
      mapnames = os.listdir(dir)
      for mapname in mapnames:
          if not mapname.endswith(".mapping"):
              continue
          name = mapname[: -len(".mapping")]
          codefile = name + ".py"
          print("converting %s to %s" % (mapname, dirprefix + codefile))
          try:
              with open(os.path.join(dir, mapname), "rb") as f:
                  map = marshal.load(f)
              if not map:
                  print("* map is empty; skipping")
              else:
                  pymap(
                      mapname, map, dirprefix + codefile, name, comments
                  )
          except ValueError as why:
              print("* conversion failed: %s" % why)
  
file_path: cpython/Tools/unicode/gencodec.py
imports: import re, os, marshal, codecs
label_desc: Use image node_id 10 for calling a global function with example usage: rewritepythondir(dir, dirprefix, comments) without return types