def find(cls: Type['Game'], name: str, *, gamedb: Path = SUPPORTED_GAMES) -> 'Game':
"""Find and create instance of a supported game.
Keyword arguments:
name: Name of the game to instantiate.
gamedb: Path to the YAML dictionary of supported games.
Returns:
Instance of the supported game.
Raises:
UnsupportedGameError: When the name is not found among supported games.
"""
with gamedb.open(encoding='utf-8') as gamestream:
games = yaml.load(gamestream)
defaults = games.get(name.lower(), None)
if defaults is None:
msg = _("Game not supported: '{name}'").format_map(locals())
raise UnsupportedGameError(msg)
return cls(name=name.capitalize(), **defaults)
评论列表
文章目录