我想在整个应用程序中索引所有方法和它们之间的连接(最终是一个包含子目录和文件的目录)。我正在使用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)