From c7cc723c87558dc17ea747bf54e6c545bdea8f03 Mon Sep 17 00:00:00 2001 From: KV Date: Sun, 5 Jul 2020 14:07:47 +0200 Subject: [PATCH] Fix the minor issues commented by the owner The owner review comments can be seen here: https://github.com/formatc1702/WireViz/pull/62 --- src/wireviz/Harness.py | 8 +------- src/wireviz/wv_helper.py | 4 ++++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index f4225bb..56b2b4d 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -4,16 +4,11 @@ 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, flatten2d +from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, nested, flatten2d, index_if_list from collections import Counter from typing import List -# Return the value indexed if it is a list, or simply the value otherwise. -# TODO: Maybe move this to wv_helper? -def index_if_list(value, index): - return value[index] if isinstance(value, list) else value - class Harness: def __init__(self): @@ -349,7 +344,6 @@ class Harness: # bundles (ignores wirecount) wirelist = [] # list all cables again, since bundles are represented as wires internally, with the category='bundle' set - # TODO: Maybe rename bundle to cable or maybe loop only [c for c in self.cables.values() if c.category == 'bundle'] for bundle in self.cables.values(): if bundle.category == 'bundle': # add each wire from each bundle to the wirelist diff --git a/src/wireviz/wv_helper.py b/src/wireviz/wv_helper.py index 222fd74..69d6550 100644 --- a/src/wireviz/wv_helper.py +++ b/src/wireviz/wv_helper.py @@ -65,3 +65,7 @@ def tuplelist2tsv(inp, header=None): for row in inp: output = output + '\t'.join(str(item) for item in row) + '\n' return output + +# Return the value indexed if it is a list, or simply the value otherwise. +def index_if_list(value, index): + return value[index] if isinstance(value, list) else value