From 3c9fbb49bc44e5d68776b5e60be2607a7ff75406 Mon Sep 17 00:00:00 2001 From: Devashish Tomar <40403260+dev1644@users.noreply.github.com> Date: Mon, 29 Nov 2021 19:56:51 +0530 Subject: [PATCH] fixed call-graph printer output filename (#973) fixed call-graph printer output filename --- slither/printers/call/call_graph.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/slither/printers/call/call_graph.py b/slither/printers/call/call_graph.py index 5adc24a89..e10db3f76 100644 --- a/slither/printers/call/call_graph.py +++ b/slither/printers/call/call_graph.py @@ -218,7 +218,12 @@ class PrinterCallGraph(AbstractPrinter): all_contracts_filename = "" if not filename.endswith(".dot"): - all_contracts_filename = f"{filename}.all_contracts.call-graph.dot" + if filename in ("", "."): + filename = "" + else: + filename += "." + all_contracts_filename = f"{filename}all_contracts.call-graph.dot" + if filename == ".dot": all_contracts_filename = "all_contracts.dot" @@ -227,7 +232,7 @@ class PrinterCallGraph(AbstractPrinter): with open(all_contracts_filename, "w", encoding="utf8") as f: info += f"Call Graph: {all_contracts_filename}\n" - # Avoid dupplicate funcitons due to different compilation unit + # Avoid duplicate functions due to different compilation unit all_functionss = [ compilation_unit.functions for compilation_unit in self.slither.compilation_units ] @@ -242,7 +247,7 @@ class PrinterCallGraph(AbstractPrinter): results.append((all_contracts_filename, content)) for derived_contract in self.slither.contracts_derived: - derived_output_filename = f"{filename}.{derived_contract.name}.call-graph.dot" + 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(