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(match_list=None, want_patched_files=True)[source]

Match a file to RetroAchievements supported files that need patches

Parameters:
  • match_list (list) – List of potential match patterns. Defaults to an empty list

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

get_ra_match(match_list=None)[source]

Match a file to RetroAchievements supported files

Parameters:

match_list (list) – List of potential match patterns. Defaults to an empty list

match_hashes(f, 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, file_dict=None)[source]

Parse info out of the dat file

parse_file(f)[source]

Parse useful info out of a specific file

parse_filename(f, file_dict=None)[source]

Parse info out of filename

parse_ra_hashes(f, file_dict=None)[source]

See if we can find ROMs that support RetroAchievements

parse_retool(f, 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