ast.py 文件源码

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

项目:monasca-analytics 作者: openstack 项目源码 文件源码
def __init__(self, span, tokens):
        super(JsonObj, self).__init__(span)
        self.props = {}
        last_prop = None
        if len(tokens) > 0:
            for toks in tokens:
                for tok in toks:
                    if isinstance(tok, DotPath):
                        if last_prop is None:
                            last_prop = tok
                        else:
                            self._set_new_prop(last_prop, tok)
                            last_prop = None
                    elif isinstance(tok, StringLit):
                        if last_prop is None:
                            last_prop = tok
                        else:
                            self._set_new_prop(last_prop, tok)
                            last_prop = None
                    elif isinstance(tok, list):
                        if last_prop is None:
                            raise p.ParseFatalException(
                                "Bug Found in JsonObj!"
                            )
                        self._set_new_prop(
                            last_prop,
                            JsonObj.dictify_array(tok)
                        )
                        last_prop = None
                    else:
                        if last_prop is None:
                            raise p.ParseFatalException(
                                "Bug Found in JsonObj!"
                            )
                        self._set_new_prop(last_prop, tok)
                        last_prop = None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号