From 6c7d700a1f76ecbf4b9324d2aa40ebcedb7f5838 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Sun, 5 Jul 2020 21:45:39 +0200 Subject: [PATCH] Remove obsolete nesting function, fine-tune table generating behavior --- src/wireviz/Harness.py | 3 +-- src/wireviz/wv_helper.py | 16 +--------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index b7be17f..0ccbcaa 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -4,7 +4,7 @@ from wireviz.DataClasses import Connector, Cable from graphviz import Graph from wireviz import wv_colors -from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, nested, \ +from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, \ nested_html_table, flatten2d, index_if_list, html_line_breaks, \ graphviz_line_breaks, remove_line_breaks from collections import Counter @@ -91,7 +91,6 @@ class Harness: f'MPN: {connector.manufacturer_part_number}' if connector.manufacturer_part_number else None, f'IPN: {connector.internal_part_number}' if connector.internal_part_number else None], [html_line_breaks(connector.notes)]] - rows = [list(filter(None, row)) for row in rows] # remove missing attributes html = nested_html_table(rows) if connector.color: # add color bar next to color info, if present diff --git a/src/wireviz/wv_helper.py b/src/wireviz/wv_helper.py index 5759a3c..016fe96 100644 --- a/src/wireviz/wv_helper.py +++ b/src/wireviz/wv_helper.py @@ -30,20 +30,6 @@ def awg_equiv(mm2): def mm2_equiv(awg): return mm2_equiv_table.get(str(awg), 'Unknown') -def nested(inp): - l = [] - for x in inp: - if isinstance(x, list): - if len(x) > 0: - n = nested(x) - if n != '': - l.append('{' + n + '}') - else: - if x is not None: - if x != '': - l.append(str(x)) - return '|'.join(l) - def nested_html_table(rows): # input: list, each item may be scalar or list # output: a parent table with one child table per parent item that is list, and one cell per parent item that is scalar @@ -57,7 +43,7 @@ def nested_html_table(rows): if cell is not None: html = f'{html}{cell}' html = f'{html}' - else: + elif row is not None: html = f'{html}{row}' html = f'{html}' return html