def get_route_info(root_path):
routing_path = os.path.join(root_path, "Uber", "uber", "routing.py")
with open(routing_path) as f:
file_contents = f.read()
tree = ast.parse(file_contents)
visitor = RouteVisitor()
visitor.visit(tree)
all_routes = visitor.routable_funcs
# Get the commit that added each route and tack it onto the details
route_linenos = sorted(set(x[0] for x in all_routes.values()))
repo = git.Repo(root_path)
blame_by_line = get_line_blames(repo, routing_path, route_linenos)
for name, details in all_routes.iteritems():
all_routes[name] = details + (blame_by_line[details[0]],)
return all_routes
评论列表
文章目录