code: def convertdir(dir, dirprefix="", nameprefix="", comments=1):
      mapnames = os.listdir(dir)
      for mapname in mapnames:
          mappathname = os.path.join(dir, mapname)
          if not os.path.isfile(mappathname):
              continue
          name = os.path.split(mapname)[1]
          name = name.replace("-", "_")
          name = name.split(".")[0]
          name = name.lower()
          name = nameprefix + name
          codefile = name + ".py"
          marshalfile = name + ".mapping"
          print(
              "converting %s to %s and %s"
              % (mapname, dirprefix + codefile, dirprefix + marshalfile)
          )
          try:
              map = readmap(os.path.join(dir, mapname))
              if not map:
                  print("* map is empty; skipping")
              else:
                  pymap(
                      mappathname,
                      map,
                      dirprefix + codefile,
                      name,
                      comments,
                  )
                  marshalmap(mappathname, map, dirprefix + marshalfile)
          except ValueError as why:
              print("* conversion failed: %s" % why)
              raise
  
file_path: cpython/Tools/unicode/gencodec.py
imports: import re, os, marshal, codecs
label_desc: Use image node_id 9 for calling a global function with example usage: convertdir(dir, dirprefix, nameprefix, comments) without return types