Skip to content

Commit

Permalink
Merge "ui: Fix tools/check_imports dot and add tools/check_imports pr…
Browse files Browse the repository at this point in the history
…int" into main
  • Loading branch information
chromy authored and Gerrit Code Review committed Sep 25, 2023
2 parents 1bb37ed + d9cccab commit e474193
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion python/tools/check_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@ def find_imports(path):


def path_to_id(path):
return path.replace('/', '_').replace('-', '_').replace('@', '_at_')
path = path.replace('/', '_')
path = path.replace('-', '_')
path = path.replace('@', '_at_')
path = path.replace('.', '_')
return path


def is_external_dep(path):
Expand Down Expand Up @@ -276,6 +280,12 @@ def do_desc(options, graph):
print(rule)


def do_print(options, graph):
for node, edges in graph.items():
for edge in edges:
print("{}\t{}".format(node, edge))


def do_dot(options, graph):

def simplify(path):
Expand Down Expand Up @@ -319,6 +329,9 @@ def main():
desc_command = subparsers.add_parser('desc', help='Print the rules')
desc_command.set_defaults(func=do_desc)

print_command = subparsers.add_parser('print', help='Print all imports')
print_command.set_defaults(func=do_print)

dot_command = subparsers.add_parser(
'dot',
help='Output dependency graph in dot format suitble for use in graphviz (e.g. ./tools/check_imports dot | dot -Tpng -ograph.png)'
Expand Down

0 comments on commit e474193

Please sign in to comment.