小编Oha*_*rry的帖子

ast python如何在不同文件的方法之间找到连接

我想在整个应用程序中索引所有方法和它们之间的连接(最终是一个包含子目录和文件的目录)。我正在使用ast,循环遍历目录直到单个文件,然后将它们加载到这样的ast对象中ast.parse(self.file_content)

我试图创建的索引是这个 连接

这是我的代码,如果相关的话。

def scan(self):
    '''
        scans a file line by line while keeping context of location and classes
        indexes a file buffer content into a ast, Abstract Syntax Trees, https://en.wikipedia.org/wiki/AST.
        Then, iterate over the elements, find relevant ones to index, and index them into the db.
    '''
    parsed_result = ast.parse(self.file_content)
    for element in parsed_result.body:
        results = self.index_element(element)


def index_element(self, element, class_name=None):
    '''

        if element is relevant, meaning method -> index
        if element is …
Run Code Online (Sandbox Code Playgroud)

python abstract-syntax-tree

5
推荐指数
1
解决办法
144
查看次数

标签 统计

abstract-syntax-tree ×1

python ×1