Skip to content

Commit

Permalink
Merge pull request #729 from crytic/add-printer-name-to-graph-printers
Browse files Browse the repository at this point in the history
Add more descriptive names to inheritance-graph + call-graph printers outputted files
  • Loading branch information
montyly authored Dec 15, 2020
2 parents b617195 + 03e2a93 commit 1c12a13
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions slither/printers/call/call_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,29 +178,31 @@ def output(self, filename):
filename(string)
"""

all_contracts_filename = ""
if not filename.endswith(".dot"):
filename += ".dot"
all_contracts_filename = f"{filename}.all_contracts.call-graph.dot"
if filename == ".dot":
filename = "all_contracts.dot"
all_contracts_filename = "all_contracts.dot"

info = ""
results = []
with open(filename, "w", encoding="utf8") as f:
info += f"Call Graph: {filename}\n"
with open(all_contracts_filename, "w", encoding="utf8") as f:
info += f"Call Graph: {all_contracts_filename}\n"
content = "\n".join(
["strict digraph {"] + [_process_functions(self.slither.functions)] + ["}"]
)
f.write(content)
results.append((filename, content))
results.append((all_contracts_filename, content))

for derived_contract in self.slither.contracts_derived:
with open(f"{derived_contract.name}.dot", "w", encoding="utf8") as f:
info += f"Call Graph: {derived_contract.name}.dot\n"
derived_output_filename = f"{filename}.{derived_contract.name}.call-graph.dot"
with open(derived_output_filename, "w", encoding="utf8") as f:
info += f"Call Graph: {derived_output_filename}\n"
content = "\n".join(
["strict digraph {"] + [_process_functions(derived_contract.functions)] + ["}"]
)
f.write(content)
results.append((filename, content))
results.append((derived_output_filename, content))

self.info(info)
res = self.generate_output(info)
Expand Down
2 changes: 1 addition & 1 deletion slither/printers/inheritance/inheritance_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def output(self, filename):
if filename == "":
filename = "contracts.dot"
if not filename.endswith(".dot"):
filename += ".dot"
filename += ".inheritance-graph.dot"
info = "Inheritance Graph: " + filename + "\n"
self.info(info)

Expand Down

0 comments on commit 1c12a13

Please sign in to comment.