From f729eda67c1f4446f20665cb2a98ef64b686157b Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Fri, 22 Oct 2021 22:17:23 +0200 Subject: [PATCH] Improve gracefulness when invoking `wireviz.parse()` without `file_out` This happened to be a regression for WireViz-Web [1], which aims to do as much in memory as possible. [1] https://github.com/daq-tools/wireviz-web. --- src/wireviz/wireviz.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wireviz/wireviz.py b/src/wireviz/wireviz.py index 95674945..a9b37498 100755 --- a/src/wireviz/wireviz.py +++ b/src/wireviz/wireviz.py @@ -40,8 +40,13 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st options = Options(**yaml_data.get('options', {})), tweak = Tweak(**yaml_data.get('tweak', {})), ) + + # When title is not given, either deduce it from filename, or use default text. if 'title' not in harness.metadata: - harness.metadata['title'] = Path(file_out).stem + if file_out is None: + harness.metadata['title'] = "WireViz diagram and BOM" + else: + harness.metadata['title'] = Path(file_out).stem # add items sections = ['connectors', 'cables', 'connections']