diff --git a/src/outils_graph.py b/src/outils_graph.py index 7b4aae024989e6ac35f556ec60d57dfa96285440..95a931351ab64c0a6bf20652f43833c14dc2e46d 100644 --- a/src/outils_graph.py +++ b/src/outils_graph.py @@ -45,22 +45,28 @@ def generate_graph_mermaid(filename, dico, label_node = True, label_edge = True, import re for match in re.finditer(r"object at (\w+)>", txt): return match.group(1) + + def quoted(label): + if not label.strip(): + return label + return f'"{label}"' + def get_graph_wo_operations_mermaid_temp(dico, txt, count): count+=1 for node in dico["nodes"]: tab= count*"\t" if(node['name']==''): if(label_node): - txt+=f"{tab}{get_id(node['id'])}(({node['xlabel']}));\n" + txt+=f"{tab}{get_id(node['id'])}(({quoted(node['xlabel'])}));\n" else: txt+=f"{tab}{get_id(node['id'])}(({' '}));\n" else: - txt+=f"{tab}{get_id(node['id'])}({node['name']});\n" + txt+=f"{tab}{get_id(node['id'])}({quoted(node['name'])});\n" for edge in dico["edges"]: tab= count*"\t" if(label_edge): - txt+=f"{tab}{get_id(edge['A'])}--{edge['label']}-->{get_id(edge['B'])};\n" + txt+=f"{tab}{get_id(edge['A'])}--{quoted(edge['label'])}-->{get_id(edge['B'])};\n" else: txt+=f"{tab}{get_id(edge['A'])}-->{get_id(edge['B'])};\n" for subworkflow in dico["subworkflows"]: