Fix the minor issues commented by the owner

The owner review comments can be seen here:
https://github.com/formatc1702/WireViz/pull/62
This commit is contained in:
KV 2020-07-05 14:07:47 +02:00
parent 42f4842387
commit c7cc723c87
2 changed files with 5 additions and 7 deletions

View File

@ -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

View File

@ -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