From 7847b7c204b7a346d39e54179edfce75b3c1e30b Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Wed, 11 Nov 2020 16:55:56 +0100 Subject: [PATCH] Display wire label in cable node Label is enclosed in [] --- src/wireviz/Harness.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index af3ac5f6..16d386d5 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -12,6 +12,7 @@ from collections import Counter from typing import List, Union from pathlib import Path +from itertools import zip_longest import re @@ -201,19 +202,23 @@ def create_graph(self) -> Graph: wirehtml.append('') # conductor table wirehtml.append(' ') - for i, connection_color in enumerate(cable.colors, 1): + colspan = 4 if cable.wirelabels else 3 + + for i, (connection_color, wirelabel) in enumerate(zip_longest(cable.colors, cable.wirelabels), 1): wirehtml.append(' ') wirehtml.append(f' ') wirehtml.append(f' ') + if cable.wirelabels: + wirehtml.append(f' ') wirehtml.append(f' ') wirehtml.append(' ') bgcolors = ['#000000'] + get_color_hex(connection_color, pad=pad) + ['#000000'] wirehtml.append(f' ') - wirehtml.append(f' ') wirehtml.append(' ') @@ -229,7 +234,7 @@ def create_graph(self) -> Graph: wireidentification.append(html_line_breaks(manufacturer_info)) # print parameters into a table row under the wire if len(wireidentification) > 0 : - wirehtml.append('
 
{wv_colors.translate_color(connection_color, self.color_mode)}[{wirelabel}]
') + wirehtml.append(f' ') wirehtml.append(' ') for j, bgcolor in enumerate(bgcolors[::-1]): # Reverse to match the curved wires when more than 2 colors - wirehtml.append(f' ') + wirehtml.append(f' ') wirehtml.append('
') wirehtml.append('
') + wirehtml.append('
') wirehtml.append(' ') for attrib in wireidentification: wirehtml.append(f' ') @@ -250,7 +255,7 @@ def create_graph(self) -> Graph: else: # shield is shown as a thin black wire attributes = f'height="2" bgcolor="#000000" border="0"' - wirehtml.append(f' ') + wirehtml.append(f' ') wirehtml.append(' ') wirehtml.append('
{attrib}
 
')