From 37c3c6ec5382052743a99d881298255b7b7ccc50 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 21 Feb 2022 12:26:29 +0100 Subject: add dtree graphviz/dot export via --export-dot / to_dot() --- lib/cli.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/cli.py') diff --git a/lib/cli.py b/lib/cli.py index 3e7865b..0de5505 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -155,7 +155,22 @@ def export_dataref(dref_file, dref): print(f"{prefix}/{k}" + "}{" + str(v[0]) + "}", file=f) +def export_dot(model, dot_prefix): + for name in model.names: + for attribute in model.attributes(name): + dot_model = model.attr_by_name[name][attribute].to_dot() + if not dot_model is None: + with open(f"{dot_prefix}{name}-{attribute}.dot", "w") as f: + print(dot_model, file=f) + + def add_standard_arguments(parser): + parser.add_argument( + "--export-dot", + metavar="PREFIX", + type=str, + help="Export model and model quality to LaTeX {PREFIX}{name}-{attribute}.dot", + ) parser.add_argument( "--export-dref", metavar="FILE", -- cgit v1.2.3