Add ability for parse() to return the Harness instance (#87)
This commit is contained in:
parent
9de33b49bd
commit
c8dc697845
@ -25,8 +25,10 @@ def parse(yaml_input, file_out=None, return_types: (None, str, Tuple[str]) = Non
|
|||||||
:param return_types: if None, then returns None; if the value is a string, then a
|
:param return_types: if None, then returns None; if the value is a string, then a
|
||||||
corresponding data format will be returned; if the value is a tuple of strings,
|
corresponding data format will be returned; if the value is a tuple of strings,
|
||||||
then for every valid format in the `return_types` tuple, another return type
|
then for every valid format in the `return_types` tuple, another return type
|
||||||
will be generated and returned in the same order; currently supports only 'png',
|
will be generated and returned in the same order; currently supports:
|
||||||
but could easily support other types
|
- "png" - will return the PNG data
|
||||||
|
- "svg" - will return the SVG data
|
||||||
|
- "harness" - will return the `Harness` instance
|
||||||
"""
|
"""
|
||||||
|
|
||||||
yaml_data = yaml.safe_load(yaml_input)
|
yaml_data = yaml.safe_load(yaml_input)
|
||||||
@ -173,7 +175,6 @@ def parse(yaml_input, file_out=None, return_types: (None, str, Tuple[str]) = Non
|
|||||||
for line in yaml_data["additional_bom_items"]:
|
for line in yaml_data["additional_bom_items"]:
|
||||||
harness.add_bom_item(line)
|
harness.add_bom_item(line)
|
||||||
|
|
||||||
|
|
||||||
if file_out is not None:
|
if file_out is not None:
|
||||||
harness.output(filename=file_out, fmt=('png', 'svg'), view=False)
|
harness.output(filename=file_out, fmt=('png', 'svg'), view=False)
|
||||||
|
|
||||||
@ -188,6 +189,8 @@ def parse(yaml_input, file_out=None, return_types: (None, str, Tuple[str]) = Non
|
|||||||
returns.append(harness.png)
|
returns.append(harness.png)
|
||||||
if 'svg' in return_types:
|
if 'svg' in return_types:
|
||||||
returns.append(harness.svg)
|
returns.append(harness.svg)
|
||||||
|
if 'harness' in return_types:
|
||||||
|
returns.append(harness)
|
||||||
|
|
||||||
return tuple(returns) if len(returns) != 1 else returns[0]
|
return tuple(returns) if len(returns) != 1 else returns[0]
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user