parameters: (romdir, datadir, pkg=None, dry_run=False)
docstring: Recursively copies all compatible ROMs in romdir
      to datadir using the proper filename for the ALE.
docstring_summary: Recursively copies all compatible ROMs in romdir
      to datadir using the proper filename for the ALE.
docstring_tokens: Recursively copies all compatible ROMs in romdir to datadir using the proper filename for the ALE .
function: def import_roms(romdir, datadir, pkg=None, dry_run=False):
      """
      Recursively copies all compatible ROMs in romdir
      to datadir using the proper filename for the ALE.
      """
      # Get all files in romdir ending in '.bin'
      entries = list(filter(lambda file: file.suffix == ".bin", scantree(romdir)))
      # Get ROM id or None from isSupportedROM
      ids = list(map(ALEInterface.isSupportedROM, entries))
      # Filter only the supported ROMs
      supported = list(filter(lambda args: args[0] is not None, zip(ids, entries)))
      # Get the set of ROMs that are unsupported
      unsupported = set(entries) - set(map(operator.itemgetter(1), supported))
  
      # Copy over supported files
      for rom, path in supported:
          identifier = str(path) if pkg is None else f"{pkg}/{path.name}"
          if not dry_run:
              copyfile(path, datadir / f"{rom}.bin")
          print(f"\033[92m{'[SUPPORTED]': <15}\033[0m {rom: >20} {identifier: >30}")
  
      print("\n")
      # Print unsuported
      for path in unsupported:
          identifier = str(path) if pkg is None else f"{pkg}/{path.name}"
          print(f"\033[91m{'[NOT SUPPORTED]': <15}\033[0m {'': >20} {identifier: >30}")
  
      # Print summary
      if not dry_run:
          print(f"\nImported {len(supported)} / {len(entries)} ROMs")
function_tokens: def import_roms ( romdir , datadir , pkg = None , dry_run = False ) : # Get all files in romdir ending in '.bin' entries = list ( filter ( lambda file : file . suffix == ".bin" , scantree ( romdir ) ) ) # Get ROM id or None from isSupportedROM ids = list ( map ( ALEInterface . isSupportedROM , entries ) ) # Filter only the supported ROMs supported = list ( filter ( lambda args : args [ 0 ] is not None , zip ( ids , entries ) ) ) # Get the set of ROMs that are unsupported unsupported = set ( entries ) - set ( map ( operator . itemgetter ( 1 ) , supported ) ) # Copy over supported files for rom , path in supported : identifier = str ( path ) if pkg is None else f"{pkg}/{path.name}" if not dry_run : copyfile ( path , datadir / f"{rom}.bin" ) print ( f"\033[92m{'[SUPPORTED]': <15}\033[0m {rom: >20} {identifier: >30}" ) print ( "\n" ) # Print unsuported for path in unsupported : identifier = str ( path ) if pkg is None else f"{pkg}/{path.name}" print ( f"\033[91m{'[NOT SUPPORTED]': <15}\033[0m {'': >20} {identifier: >30}" ) # Print summary if not dry_run : print ( f"\nImported {len(supported)} / {len(entries)} ROMs" )