ROMParser

ROMParser will parse out useful information from both filenames and parsed .dat files. These are things like regions, languages, and various flags for things like Demos or BIOS that then can be used to choose the best ROM.

If explicit languages are not found, then ROMParser will generally assign a language based on the region. This is not true for regions like Scandinavia, where it could be any of multiple languages.

ROMParser can also determine whether ROMs are compatible with RetroAchievements. It does this in two passes - first by matching to the hash (if RA uses MD5 hashes) or the name. Secondly, for ROMs that require patches it will search by those by name, matching to things like region/version. In the second case, if a patch is needed it will pull that out. This does rely on the naming on RA being pretty accurate, which is mostly the case but some may be missed.

For more details on the ROMParser arguments, see the config file documentation.

API

class romsearch.ROMParser(platform, game, dat=None, retool=None, ra_hashes=None, config_file=None, config=None, platform_config=None, default_config=None, regex_config=None, logger=None, log_line_sep='=', log_line_length=100)[source]

ROM parser tool

This works per-game, per-platform, so must be specified here

Parameters:
  • platform (str) – Platform name

  • game (str) – Game name

  • dat (dict) – Parsed dat dictionary. Defaults to None, which will try to load the dat file if it exists

  • retool (dict) – Retool dictionary. Defaults to None, which will try to load the file if it exists

  • ra_hashes (dict) – RA hash dictionary. Defaults to None, which will try to load the file if it exists

  • config_file (str, optional) – path to config file. Defaults to None.

  • config (dict, optional) – configuration dictionary. Defaults to None.

  • platform_config (dict, optional) – platform configuration dictionary. Defaults to None.

  • default_config (dict, optional) – default configuration dictionary. Defaults to None.

  • regex_config (dict, optional) – regex configuration dictionary. Defaults to None.

  • logger (logging.Logger, optional) – logger instance. Defaults to None.

  • log_line_length (int, optional) – Line length of log. Defaults to 100

Todo

For the RetroAchievements, there are hacks and unlicensed stuff that seems to work differently

finalise_file_dict(file_dict)[source]

Do any last minute finalisation to the file dict

get_parsed_match(file_dict, want_patched_files=True)[source]

Match a file to RetroAchievements supported files that potentially need patches

Parameters:
  • file_dict (dict) – Dictionary of ROM descriptions

  • want_patched_files (bool) – Whether we’re looking for hashes with patches or not. Defaults to True

get_ra_dict()[source]

Get a big dictionary of RA hashes with useful info

get_ra_match(file_dict)[source]

Match a file to RetroAchievements supported files

Parameters:

file_dict (dict) – Dictionary of ROM descriptions

match_hashes(file_dict)[source]

Get whether ROM has cheevos by various potential hash methods

Parameters:
  • f (str) – Filename

  • file_dict (dict) – Dictionary of ROM descriptions

parse_dat(f=None, file_dict=None)[source]

Parse info out of the dat file

Parameters:
  • f (str) – Fallback filename

  • file_dict (dict) – Dictionary of file info

parse_file(f=None, file_dict=None, title_pos=None)[source]

Parse useful info out of a specific file

Parameters:
  • f (str) – Filename. Will only use this if something more suitable isn’t found

  • file_dict (dict) – Dictionary of file properties

  • title_pos (int, optional) – Title position for compilations. Defaults to None.

parse_filename(f=None, file_dict=None, title_pos=None)[source]

Parse info out of filename

Parameters:
  • f (str) – filename. Defaults to None, which will pull the original name out of the dict

  • title_pos (int) – Title position for compilations. Defaults to None

  • file_dict (dict) – Existing file dictionary. Defaults to None, which will create an empty one

parse_ra_hashes(file_dict=None)[source]

See if we can find ROMs that support RetroAchievements

Note that this requires a bunch of parsing to have already occurred

parse_retool(file_dict=None)[source]

Parse info out of the retool file

run(files)[source]

Run the ROM parser

set_game_category(file_dict)[source]

If a dat category hasn’t been set, set it to game

set_implicit_languages(file_dict)[source]

Set implicit language from region, if we don’t already have languages