Skip to content

Commit

Permalink
Improve gracefulness when invoking wireviz.parse() without file_out
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
amotl authored and formatc1702 committed Oct 25, 2021
1 parent be1ecd4 commit 80b7a54
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/wireviz/wireviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down

0 comments on commit 80b7a54

Please sign in to comment.