summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2022-02-18 16:15:00 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2022-02-18 16:15:00 +0100
commit32213cdb49a08bd0f2012baaefb031d0726dc4bf (patch)
tree4be470e660b0ce66de4a12b503a2e102f0f5789f
parent05ef7cf244c84be698cdf83c5e18104d4ed5dc70 (diff)
move dataref export to cli.py
-rwxr-xr-xbin/analyze-archive.py10
-rwxr-xr-xbin/analyze-kconfig.py10
-rw-r--r--lib/cli.py12
3 files changed, 14 insertions, 18 deletions
diff --git a/bin/analyze-archive.py b/bin/analyze-archive.py
index f48afd8..7fb5719 100755
--- a/bin/analyze-archive.py
+++ b/bin/analyze-archive.py
@@ -1036,15 +1036,7 @@ if __name__ == "__main__":
)
dref["constructor duration"] = (constructor_duration, r"\second")
dref["regression duration"] = (fit_duration, r"\second")
- with open(args.export_dref, "w") as f:
- for k, v in sorted(dref.items()):
- if type(v) is not tuple:
- v = (v, None)
- if v[1] is None:
- prefix = r"\drefset{"
- else:
- prefix = r"\drefset" + f"[unit={v[1]}]" + "{"
- print(f"{prefix}/{k}" + "}{" + str(v[0]) + "}", file=f)
+ dfatool.cli.export_dataref(args.export_dref, dref)
if args.export_webconf:
if not pta:
diff --git a/bin/analyze-kconfig.py b/bin/analyze-kconfig.py
index e8b946a..db6cf40 100755
--- a/bin/analyze-kconfig.py
+++ b/bin/analyze-kconfig.py
@@ -330,15 +330,7 @@ def main():
)
dref["constructor duration"] = (constructor_duration, r"\second")
dref["regression duration"] = (fit_duration, r"\second")
- with open(args.export_dref, "w") as f:
- for k, v in sorted(dref.items()):
- if type(v) is not tuple:
- v = (v, None)
- if v[1] is None:
- prefix = r"\drefset{"
- else:
- prefix = r"\drefset" + f"[unit={v[1]}]" + "{"
- print(f"{prefix}/{k}" + "}{" + str(v[0]) + "}", file=f)
+ dfatool.cli.export_dataref(args.export_dref, dref)
if args.config:
kconf = kconfiglib.Kconfig(args.kconfig_path)
diff --git a/lib/cli.py b/lib/cli.py
index 1ee1f33..3e7865b 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -143,6 +143,18 @@ def model_quality_table(header, result_lists, info_list):
print(buf)
+def export_dataref(dref_file, dref):
+ with open(dref_file, "w") as f:
+ for k, v in sorted(dref.items()):
+ if type(v) is not tuple:
+ v = (v, None)
+ if v[1] is None:
+ prefix = r"\drefset{"
+ else:
+ prefix = r"\drefset" + f"[unit={v[1]}]" + "{"
+ print(f"{prefix}/{k}" + "}{" + str(v[0]) + "}", file=f)
+
+
def add_standard_arguments(parser):
parser.add_argument(
"--export-dref",