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.
This commit is contained in:
Andreas Motl 2021-10-22 22:17:23 +02:00 committed by Daniel Rojas
parent be1ecd4f63
commit 80b7a5407b

View File

@ -40,8 +40,13 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st
options = Options(**yaml_data.get('options', {})), options = Options(**yaml_data.get('options', {})),
tweak = Tweak(**yaml_data.get('tweak', {})), 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: 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 # add items
sections = ['connectors', 'cables', 'connections'] sections = ['connectors', 'cables', 'connections']