From 43d7665b8e19235be683536873250bd628a74de2 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Thu, 30 Jul 2020 08:07:24 +0200 Subject: [PATCH] Simplify code and rename variables --- src/wireviz/Harness.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index c4c5869..b0d51c6 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -177,19 +177,18 @@ class Harness: 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}{bla}' + for cell in wirerow: + wirehtml = f'{wirehtml}{cell}' wirehtml = f'{wirehtml}' bgcolors = ['#000000'] + get_color_hex(connection_color, pad=pad) + ['#000000'] - wirehtml = f'{wirehtml}' + wirehtml = f'{wirehtml}' if(cable.category == 'bundle'): # for bundles individual wires can have part information # create a list of wire parameters @@ -202,17 +201,17 @@ class Harness: wireidentification.append(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 +220,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}
 
'