From 68a0a21a56bd0ccb83f15da1244e879770384f99 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 29 Oct 2024 17:34:16 +0100 Subject: [PATCH] chore: generalize dot attributes so that they're easier to extend --- src/rebdhuhn/graphviz.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rebdhuhn/graphviz.py b/src/rebdhuhn/graphviz.py index c64bc4c..e24cb04 100644 --- a/src/rebdhuhn/graphviz.py +++ b/src/rebdhuhn/graphviz.py @@ -160,7 +160,10 @@ def convert_graph_to_dot(ebd_graph: EbdGraph) -> str: f'{ebd_graph.metadata.chapter}

' f'{ebd_graph.metadata.sub_chapter}



' ) - dot_code = "digraph D {\n" f'{ADD_INDENT}labelloc="t";\n{ADD_INDENT}label=<{header}>;\n' + dot_attributes: dict[str, str] = {f"'{ADD_INDENT}labelloc": '"t"', "label": f"<{header}>"} + dot_code = "digraph D {\n" + for dot_attr_key, dot_attr_value in dot_attributes.items(): + dot_code += f"{dot_attr_key}={dot_attr_value};\n" assert len(nx_graph["Start"]) == 1, "Start node must have exactly one outgoing edge." dot_code += _convert_nodes_to_dot(ebd_graph, ADD_INDENT) + "\n\n" dot_code += "\n".join(_convert_edges_to_dot(ebd_graph, ADD_INDENT)) + "\n"