reprconf.py 文件源码

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

项目:watcher 作者: nosmokingbandit 项目源码 文件源码
def _build_call35(self, o):
        """
        Workaround for python 3.5 _ast.Call signature, docs found here
        https://greentreesnakes.readthedocs.org/en/latest/nodes.html
        """
        import ast
        callee = self.build(o.func)
        args = []
        if o.args is not None:
            for a in o.args:
                if isinstance(a, ast.Starred):
                    args.append(self.build(a.value))
                else:
                    args.append(self.build(a))
        kwargs = {}
        for kw in o.keywords:
            if kw.arg is None: # double asterix `**`
                rst = self.build(kw.value)
                if not isinstance(rst, dict):
                    raise TypeError("Invalid argument for call."
                                    "Must be a mapping object.")
                # give preference to the keys set directly from arg=value
                for k, v in rst.items():
                    if k not in kwargs:
                        kwargs[k] = v
            else: # defined on the call as: arg=value
                kwargs[kw.arg] = self.build(kw.value)
        return callee(*args, **kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号