Add suggested changes

This commit is contained in:
Daniel Rojas 2020-08-10 16:44:13 +02:00
parent 9152900f66
commit eefea241a3
2 changed files with 9 additions and 12 deletions

View File

@ -103,7 +103,7 @@ class Harness:
if connector.color: # add color bar next to color info, if present 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 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': if connector.style != 'simple':
pinhtml = [] pinhtml = []
@ -123,8 +123,7 @@ class Harness:
pinhtml.append('</table>') pinhtml.append('</table>')
pinhtml = '\n'.join(pinhtml) html = [row.replace('<!-- connector table -->', '\n'.join(pinhtml)) for row in html]
html = [x.replace('<!-- connector table -->', pinhtml) for x in html]
html = '\n'.join(html) html = '\n'.join(html)
dot.node(connector.name, label=f'<\n{html}\n>', shape='none', margin='0', style='filled', fillcolor='white') dot.node(connector.name, label=f'<\n{html}\n>', shape='none', margin='0', style='filled', fillcolor='white')
@ -179,7 +178,7 @@ class Harness:
if cable.color: # add color bar next to color info, if present 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 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 = []
wirehtml.append('<table border="0" cellspacing="0" cellborder="0">') # conductor table wirehtml.append('<table border="0" cellspacing="0" cellborder="0">') # conductor table
@ -237,9 +236,7 @@ class Harness:
wirehtml.append('<tr><td>&nbsp;</td></tr>') wirehtml.append('<tr><td>&nbsp;</td></tr>')
wirehtml.append('</table>') wirehtml.append('</table>')
wirehtml = '\n'.join(wirehtml) html = [row.replace('<!-- wire table -->', '\n'.join(wirehtml)) for row in html]
html = [x.replace('<!-- wire table -->', wirehtml) for x in html]
# connections # connections
for connection_color in cable.connections: for connection_color in cable.connections:
@ -254,14 +251,14 @@ class Harness:
code_left_2 = f'{cable.name}:w{connection_color.via_port}:w' code_left_2 = f'{cable.name}:w{connection_color.via_port}:w'
dot.edge(code_left_1, code_left_2) 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 '' 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 if connection_color.to_port is not None: # connect to right
code_right_1 = f'{cable.name}:w{connection_color.via_port}:e' 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 '' 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' code_right_2 = f'{connection_color.to_name}{to_port}:w'
dot.edge(code_right_1, code_right_2) 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 '' 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) html = '\n'.join(html)
dot.node(cable.name, label=f'<\n{html}\n>', shape='box', dot.node(cable.name, label=f'<\n{html}\n>', shape='box',

View File

@ -47,9 +47,9 @@ def nested_html_table(rows):
html.append('</tr></table>') html.append('</tr></table>')
html.append('</td></tr>') html.append('</td></tr>')
elif row is not None: elif row is not None:
html.append(f'<tr><td>') html.append('<tr><td>')
html.append(f'{row}') html.append(row)
html.append(f'</td></tr>') html.append('</td></tr>')
html.append('</table>') html.append('</table>')
return html return html