walker.py 文件源码

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

项目:biblio 作者: b1naryth1ef 项目源码 文件源码
def visit_ClassDef(self, node):
        obj = {
            'type': 'class',
            'name': node.name,
            'docstring': self.get_docstring(node),
            'bases': list(ifilter(lambda k: k.get('name') != 'object', [
                {'name': i.id} if isinstance(i, ast.Name) else self.visit(i) for i in node.bases
            ])),
            'attributes': [],
            'functions': [],
        }

        for node in imap(self.visit, node.body):
            if node['type'] == 'function':
                obj['functions'].append(node)
            elif node['type'] == 'assign':
                obj['attributes'].append(node)

        return obj
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号