Skip to content

Commit

Permalink
Fix bug in refactoring of #55, add SVG output option
Browse files Browse the repository at this point in the history
  • Loading branch information
17o2 committed Jul 5, 2020
1 parent 144c99e commit de1e45f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/wireviz/Harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,15 @@ def png(self):
data.seek(0)
return data.read()

@property
def svg(self):
from io import BytesIO
graph = self.create_graph()
data = BytesIO()
data.write(graph.pipe(format='svg'))
data.seek(0)
return data.read()

This comment has been minimized.

Copy link
@17o2

17o2 Jul 5, 2020

Author Collaborator

Maybe SVG output could be simplified since it's not binary? Or the png() and svg() functions could be somehow merged or restructured to avoid duplicated code?


def output(self, filename, directory='_output', view=False, cleanup=True, fmt='pdf', gen_bom=False):
# graphical output
graph = self.create_graph()
Expand Down
4 changes: 3 additions & 1 deletion src/wireviz/wireviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,10 @@ def check_designators(what, where):

if 'png' in return_types:
returns.append(harness.png)
if 'svg' in return_types:
returns.append(harness.svg)

return tuple(returns) if len(returns) != 1 else returns
return tuple(returns) if len(returns) != 1 else returns[0]


def parse_file(yaml_file, file_out=None, generate_bom=False):
Expand Down

0 comments on commit de1e45f

Please sign in to comment.