From 34907ed26e0d82153beb5195aa5ee061d595d11e Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Wed, 12 Aug 2020 22:59:46 +0200 Subject: [PATCH] Add whitespace to GraphViz HTML for readability --- src/wireviz/Harness.py | 64 +++++++++++++++++++++------------------- src/wireviz/wv_helper.py | 16 +++++----- 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index 635fae91..af7946e3 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -112,16 +112,16 @@ def create_graph(self) -> Graph: for pin, pinlabel in zip(connector.pins, connector.pinlabels): if connector.hide_disconnected_pins and not connector.visible_pins.get(pin, False): continue - pinhtml.append('') + pinhtml.append(' ') if connector.ports_left: - pinhtml.append(f'{pin}') + pinhtml.append(f' {pin}') if pinlabel: - pinhtml.append(f'{pinlabel}') + pinhtml.append(f' {pinlabel}') if connector.ports_right: - pinhtml.append(f'{pin}') - pinhtml.append('') + pinhtml.append(f' {pin}') + pinhtml.append(' ') - pinhtml.append('') + pinhtml.append(' ') html = [row.replace('', '\n'.join(pinhtml)) for row in html] @@ -182,22 +182,24 @@ def create_graph(self) -> Graph: wirehtml = [] wirehtml.append('') # conductor table - wirehtml.append('') + wirehtml.append(' ') for i, connection_color in enumerate(cable.colors, 1): - wirehtml.append('') - wirehtml.append(f'') - wirehtml.append(f'') - wirehtml.append(f'') - wirehtml.append('') + wirehtml.append(' ') + wirehtml.append(f' ') + wirehtml.append(f' ') + wirehtml.append(f' ') + wirehtml.append(' ') bgcolors = ['#000000'] + get_color_hex(connection_color, pad=pad) + ['#000000'] - wirehtml.append(f'') + wirehtml.append(' ') if(cable.category == 'bundle'): # for bundles individual wires can have part information # create a list of wire parameters wireidentification = [] @@ -210,20 +212,20 @@ 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('') if cable.shield: - wirehtml.append('') # spacer - wirehtml.append('') - wirehtml.append('') - wirehtml.append('') - wirehtml.append('') - wirehtml.append('') + wirehtml.append(' ') # spacer + wirehtml.append(' ') + wirehtml.append(' ') + wirehtml.append(' ') + wirehtml.append(' ') + wirehtml.append(' ') if isinstance(cable.shield, str): # shield is shown with specified color and black borders shield_color_hex = wv_colors.get_color_hex(cable.shield)[0] @@ -231,10 +233,10 @@ 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('
 
 
{wv_colors.translate_color(connection_color, self.color_mode)}
{wv_colors.translate_color(connection_color, self.color_mode)}
') - wirehtml.append('') + wirehtml.append(f' ') + wirehtml.append(f' ') + wirehtml.append(f' ') + wirehtml.append('
') + 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('
') - wirehtml.append('
') + wirehtml.append('
') - wirehtml.append('') + wirehtml.append(' ') + wirehtml.append(f' ') + wirehtml.append('
') + wirehtml.append(' ') for attrib in wireidentification: - wirehtml.append(f'') - wirehtml.append('
{attrib}
') - wirehtml.append('
{attrib}
') + wirehtml.append('
 
Shield
 
Shield
 
') + wirehtml.append('  ') + wirehtml.append(' ') html = [row.replace('', '\n'.join(wirehtml)) for row in html] diff --git a/src/wireviz/wv_helper.py b/src/wireviz/wv_helper.py index 102aceac..d98fde1e 100644 --- a/src/wireviz/wv_helper.py +++ b/src/wireviz/wv_helper.py @@ -39,17 +39,17 @@ def nested_html_table(rows): for row in rows: if isinstance(row, List): if len(row) > 0 and any(row): - html.append('') - html.append('') + html.append(' ') + html.append(f' ') + html.append('
') + html.append(' ') for cell in row: if cell is not None: - html.append(f'') - html.append('
{cell}
') - html.append('
{cell}
') + html.append(' ') elif row is not None: - html.append('') - html.append(row) - html.append('') + html.append(' ') + html.append(f' {row}') + html.append(' ') html.append('') return html