def ingest(self, rootdir):
"""
Collect all the .py files to perform analysis upon
"""
if not os.path.isdir(rootdir):
raise Exception("directory %s passed in is not a dir" % rootdir)
self.__target_dir = rootdir
# walk the dirs/files
for root, subdir, files in os.walk(self.__target_dir):
for f in files:
if f.endswith(".py"):
fullpath = root + os.sep + f
contents = file(fullpath).read()
tree = ast.parse(contents)
self.__fn_to_ast[fullpath] = tree
# potentially analyze .html files for jinja templates
if self.perform_jinja_analysis:
self.__template_dir = self.get_template_dir()
评论列表
文章目录