Skip to content

Commit

Permalink
Add suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
formatc1702 committed Aug 10, 2020
1 parent 9152900 commit eefea24
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
15 changes: 6 additions & 9 deletions src/wireviz/Harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def create_graph(self) -> Graph:

if connector.color: # add color bar next to color info, if present
colorbar = f' bgcolor="{wv_colors.translate_color(connector.color, "HEX")}" width="4"></td>' # leave out '<td' from string to preserve any existing attributes of the <td> tag
html = [x.replace('><!-- colorbar --></td>', colorbar) for x in html]
html = [row.replace('><!-- colorbar --></td>', colorbar) for row in html]

if connector.style != 'simple':
pinhtml = []
Expand All @@ -123,8 +123,7 @@ def create_graph(self) -> Graph:

pinhtml.append('</table>')

pinhtml = '\n'.join(pinhtml)
html = [x.replace('<!-- connector table -->', pinhtml) for x in html]
html = [row.replace('<!-- connector table -->', '\n'.join(pinhtml)) for row in html]

html = '\n'.join(html)
dot.node(connector.name, label=f'<\n{html}\n>', shape='none', margin='0', style='filled', fillcolor='white')
Expand Down Expand Up @@ -179,7 +178,7 @@ def create_graph(self) -> Graph:

if cable.color: # add color bar next to color info, if present
colorbar = f' bgcolor="{wv_colors.translate_color(cable.color, "HEX")}" width="4"></td>' # leave out '<td' from string to preserve any existing attributes of the <td> tag
html = [x.replace('><!-- colorbar --></td>', colorbar) for x in html]
html = [row.replace('><!-- colorbar --></td>', colorbar) for row in html]

wirehtml = []
wirehtml.append('<table border="0" cellspacing="0" cellborder="0">') # conductor table
Expand Down Expand Up @@ -237,9 +236,7 @@ def create_graph(self) -> Graph:
wirehtml.append('<tr><td>&nbsp;</td></tr>')
wirehtml.append('</table>')

wirehtml = '\n'.join(wirehtml)

html = [x.replace('<!-- wire table -->', wirehtml) for x in html]
html = [row.replace('<!-- wire table -->', '\n'.join(wirehtml)) for row in html]

# connections
for connection_color in cable.connections:
Expand All @@ -254,14 +251,14 @@ def create_graph(self) -> Graph:
code_left_2 = f'{cable.name}:w{connection_color.via_port}:w'
dot.edge(code_left_1, code_left_2)
from_string = f'{connection_color.from_name}:{connection_color.from_port}' if self.connectors[connection_color.from_name].show_name else ''
html = [x.replace(f'<!-- {connection_color.via_port}_in -->', from_string) for x in html]
html = [row.replace(f'<!-- {connection_color.via_port}_in -->', from_string) for row in html]
if connection_color.to_port is not None: # connect to right
code_right_1 = f'{cable.name}:w{connection_color.via_port}:e'
to_port = f':p{connection_color.to_port}l' if self.connectors[connection_color.to_name].style != 'simple' else ''
code_right_2 = f'{connection_color.to_name}{to_port}:w'
dot.edge(code_right_1, code_right_2)
to_string = f'{connection_color.to_name}:{connection_color.to_port}' if self.connectors[connection_color.to_name].show_name else ''
html = [x.replace(f'<!-- {connection_color.via_port}_out -->', to_string) for x in html]
html = [row.replace(f'<!-- {connection_color.via_port}_out -->', to_string) for row in html]

html = '\n'.join(html)
dot.node(cable.name, label=f'<\n{html}\n>', shape='box',
Expand Down
6 changes: 3 additions & 3 deletions src/wireviz/wv_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def nested_html_table(rows):
html.append('</tr></table>')
html.append('</td></tr>')
elif row is not None:
html.append(f'<tr><td>')
html.append(f'{row}')
html.append(f'</td></tr>')
html.append('<tr><td>')
html.append(row)
html.append('</td></tr>')
html.append('</table>')
return html

Expand Down

0 comments on commit eefea24

Please sign in to comment.