config.py 文件源码

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

项目:imouto 作者: Hanaasagi 项目源码 文件源码
def from_mapping(self, *mapping, **kwargs) -> bool:
        """ Updates the config like :meth:`update` but ignoring items with
        non-upper keys.
        """
        if len(mapping) > 1:
            raise TypeError(
                'expected at most 1 positional argument, got %d' % len(mapping)
            )
        dict_: dict = {}
        if len(mapping) == 1:
            dict_ = mapping[0]
            if not isinstance(dict_, dict):
                raise TypeError(
                    'expected dict type argument, got %s' % dict_.__class__
                )

        for key, value in chain(*map(methodcaller('items'),
                                     (dict_, kwargs))):
            if key.isupper():
                self.data[key] = value
        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号