diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index c4c5869..69e0443 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -86,11 +86,11 @@ class Harness: if connection_color.to_port is not None: # connect to right self.connectors[connection_color.to_name].ports_left = True - for key, connector in self.connectors.items(): + for connector in self.connectors.values(): rows = [[connector.name if connector.show_name else None], [f'P/N: {connector.pn}' if connector.pn else None, - manufacturer_info_field(connector.manufacturer, connector.mpn)], + html_line_breaks(manufacturer_info_field(connector.manufacturer, connector.mpn))], [html_line_breaks(connector.type), html_line_breaks(connector.subtype), f'{connector.pincount}-pin' if connector.show_pincount else None, @@ -123,7 +123,7 @@ class Harness: html = html.replace('', pinhtml) - dot.node(key, label=f'<{html}>', shape='none', margin='0', style='filled', fillcolor='white') + dot.node(connector.name, label=f'<{html}>', shape='none', margin='0', style='filled', fillcolor='white') if len(connector.loops) > 0: dot.attr('edge', color='#000000:#ffffff:#000000') @@ -144,7 +144,7 @@ class Harness: # if so, pad single-color wires to make all wires of equal thickness pad = any(len(colorstr) > 2 for cable in self.cables.values() for colorstr in cable.colors) - for key, cable in self.cables.items(): + for cable in self.cables.values(): awg_fmt = '' if cable.show_equiv: @@ -158,9 +158,11 @@ class Harness: rows = [[cable.name if cable.show_name else None], [f'P/N: {cable.pn}' if (cable.pn and not isinstance(cable.pn, list)) else None, - manufacturer_info_field(cable.manufacturer, cable.mpn) if not isinstance(cable.manufacturer, list) else None], + html_line_breaks(manufacturer_info_field( + cable.manufacturer if not isinstance(cable.manufacturer, list) else None, + cable.mpn if not isinstance(cable.mpn, list) else None))], [html_line_breaks(cable.type), - f'{len(cable.colors)}x' if cable.show_wirecount else None, + f'{cable.wirecount}x' if cable.show_wirecount else None, f'{cable.gauge} {cable.gauge_unit}{awg_fmt}' if cable.gauge else None, '+ S' if cable.shield else None, f'{cable.length} m' if cable.length > 0 else None, @@ -172,24 +174,23 @@ class Harness: if cable.color: # add color bar next to color info, if present colorbar = f' bgcolor="{wv_colors.translate_color(cable.color, "HEX")}" width="4">' # leave out ' tag html = html.replace('>', colorbar) - + wirehtml = '' # conductor table wirehtml = f'{wirehtml}' for i, connection_color in enumerate(cable.colors, 1): - p = [] - p.append(f'') - p.append(wv_colors.translate_color(connection_color, self.color_mode)) - p.append(f'') + wirerow = [f'', + wv_colors.translate_color(connection_color, self.color_mode), + f''] wirehtml = f'{wirehtml}' - for bla in p: - wirehtml = f'{wirehtml}' + for cell in wirerow: + wirehtml = f'{wirehtml}' wirehtml = f'{wirehtml}' bgcolors = ['#000000'] + get_color_hex(connection_color, pad=pad) + ['#000000'] - wirehtml = f'{wirehtml}
 
{bla}{cell}
' + wirehtml = f'{wirehtml}' if(cable.category == 'bundle'): # for bundles individual wires can have part information # create a list of wire parameters @@ -199,20 +200,20 @@ class Harness: manufacturer_info = manufacturer_info_field(cable.manufacturer[i - 1] if isinstance(cable.manufacturer, list) else None, cable.mpn[i - 1] if isinstance(cable.mpn, list) else None) if manufacturer_info: - wireidentification.append(manufacturer_info) + wireidentification.append(html_line_breaks(manufacturer_info)) # print parameters into a table row under the wire if(len(wireidentification) > 0): - wirehtml = f'{wirehtml}
' for j, bgcolor in enumerate(bgcolors[::-1]): # Reverse to match the curved wires when more than 2 colors - wirehtml = f'{wirehtml}' + wirehtml = f'{wirehtml}' wirehtml = wirehtml + '
' + wirehtml = f'{wirehtml}' if cable.shield: - p = ['', 'Shield', ''] + wirerow = ['', 'Shield', ''] wirehtml = f'{wirehtml}' # spacer wirehtml = f'{wirehtml}' - for bla in p: - wirehtml = wirehtml + f'' + for cell in wirerow: + wirehtml = wirehtml + f'' wirehtml = f'{wirehtml}' if isinstance(cable.shield, str): # shield is shown with specified color and black borders @@ -221,7 +222,7 @@ class Harness: else: # shield is shown as a thin black wire attributes = f'height="2" bgcolor="#000000" border="0"' - wirehtml = f'{wirehtml}' + wirehtml = f'{wirehtml}' wirehtml = f'{wirehtml}' wirehtml = f'{wirehtml}
' for attrib in wireidentification: wirehtml = f'{wirehtml}' wirehtml = f'{wirehtml}
{attrib}
 
{bla}{cell}
 
'