From 116c03400f8d3bca1ece576c44da9b3dab92bca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Kl=C3=B6ffel?= <145490354+christophkloeffel@users.noreply.github.com> Date: Mon, 17 Jun 2024 13:53:40 +0200 Subject: [PATCH] adds --dot argument to specify the dot executable path (#41) * adds --dot argument to specify the dot executable path * adds link to graphviz in help message --- lobster/tools/core/html_report.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lobster/tools/core/html_report.py b/lobster/tools/core/html_report.py index 4971be65..5473741a 100755 --- a/lobster/tools/core/html_report.py +++ b/lobster/tools/core/html_report.py @@ -36,9 +36,9 @@ LOBSTER_GH = "https://github.com/bmw-software-engineering/lobster" -def is_dot_available(): +def is_dot_available(dot): try: - subprocess.run(["dot", "-V"], + subprocess.run([dot if dot else "dot", "-V"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="UTF-8", @@ -113,7 +113,7 @@ def xref_item(item, link=True, brief=False): return rv -def create_policy_diagram(doc, report): +def create_policy_diagram(doc, report, dot): assert isinstance(doc, htmldoc.Document) assert isinstance(report, Report) @@ -145,7 +145,7 @@ def create_policy_diagram(doc, report): graph_name = os.path.join(tmp_dir, "graph.dot") with open(graph_name, "w", encoding="UTF-8") as tmp_fd: tmp_fd.write(graph) - svg = subprocess.run(["dot", "-Tsvg", graph_name], + svg = subprocess.run([dot if dot else "dot", "-Tsvg", graph_name], stdout=subprocess.PIPE, encoding="UTF-8", check=True) @@ -258,7 +258,7 @@ def write_item_box_end(doc): doc.add_line('') -def write_html(fd, report): +def write_html(fd, report, dot): assert isinstance(report, Report) doc = htmldoc.Document( @@ -362,10 +362,10 @@ def write_html(fd, report): doc.add_heading(3, "Coverage") create_item_coverage(doc, report) doc.add_line('') - if is_dot_available(): + if is_dot_available(dot): doc.add_line('