curse.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:mccurse 作者: khardix 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号