Skip to content

Commit

Permalink
Apply some manual fixes, reapply black
Browse files Browse the repository at this point in the history
  • Loading branch information
formatc1702 committed Oct 11, 2021
1 parent 7b2db0b commit 96c3b90
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 30 deletions.
10 changes: 4 additions & 6 deletions src/wireviz/DataClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,12 @@ def __post_init__(self) -> None:
raise Exception("Pins are not unique")

if self.show_name is None:
self.show_name = (
not self.autogenerate
) # hide auto-generated designators by default
# hide auto-generated designators by default
self.show_name = not self.autogenerate

if self.show_pincount is None:
self.show_pincount = (
self.style != "simple"
) # hide pincount for simple (1 pin) connectors by default
# hide pincount for simple (1 pin) connectors by default
self.show_pincount = self.style != "simple"

for loop in self.loops:
# TODO: check that pins to connect actually exist
Expand Down
15 changes: 6 additions & 9 deletions src/wireviz/Harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,15 @@ def connect(
raise Exception(
f"{via_name}:{via_wire} is used for more than one wire."
)
via_wire = (
cable.colors.index(via_wire) + 1
) # list index starts at 0, wire IDs start at 1
# list index starts at 0, wire IDs start at 1
via_wire = cable.colors.index(via_wire) + 1
elif via_wire in cable.wirelabels:
if cable.wirelabels.count(via_wire) > 1:
raise Exception(
f"{via_name}:{via_wire} is used for more than one wire."
)
via_wire = (
cable.wirelabels.index(via_wire) + 1
) # list index starts at 0, wire IDs start at 1
# list index starts at 0, wire IDs start at 1
via_wire = cable.wirelabels.index(via_wire) + 1

from_pin_id = (
self.connectors[from_name].pins.index(from_pin)
Expand Down Expand Up @@ -360,9 +358,8 @@ def create_graph(self) -> Graph:
html.extend(nested_html_table(rows, html_bgcolor_attr(cable.bgcolor)))

wirehtml = []
wirehtml.append(
'<table border="0" cellspacing="0" cellborder="0">'
) # conductor table
# conductor table
wirehtml.append('<table border="0" cellspacing="0" cellborder="0">')
wirehtml.append(" <tr><td>&nbsp;</td></tr>")

for i, (connection_color, wirelabel) in enumerate(
Expand Down
20 changes: 8 additions & 12 deletions src/wireviz/wireviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,15 @@ def check_designators(what, where): # helper function
break
else:
raise Exception("First item not found anywhere.")
expected_index = (
1 - expected_index
) # flip once since it is flipped back at the *beginning* of every loop
# flip once since it is flipped back at the *beginning* of every loop
expected_index = 1 - expected_index

# check that all iterable items (lists and dicts) are the same length
# and that they are alternating between connectors and cables/bundles, starting with either
itemcount = None
for item in connection:
expected_index = (
1 - expected_index
) # make sure items alternate between connectors and cables
# make sure items alternate between connectors and cables
expected_index = 1 - expected_index
expected_section = alternating_sections[expected_index]
if isinstance(item, list):
itemcount_new = len(item)
Expand Down Expand Up @@ -182,19 +180,17 @@ def check_designators(what, where): # helper function
id = item[0][0] # TODO: make more elegant/robust/pythonic
if id in harness.cables:
for j, con in enumerate(item):
if (
i == 0
): # list started with a cable, no connector to join on left side
if i == 0:
# list started with a cable, no connector to join on left side
from_name = None
from_pin = None
else:
from_name = connection_list[i - 1][j][0]
from_pin = connection_list[i - 1][j][1]
via_name = item[j][0]
via_pin = item[j][1]
if (
i == len(connection_list) - 1
): # list ends with a cable, no connector to join on right side
if i == len(connection_list) - 1:
# list ends with a cable, no connector to join on right side
to_name = None
to_pin = None
else:
Expand Down
5 changes: 2 additions & 3 deletions src/wireviz/wv_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ def expand(yaml_data):
else: # a == b
output.append(a) # range of length 1
except:
output.append(
e
) # '-' was not a delimiter between two ints, pass e through unchanged
# '-' was not a delimiter between two ints, pass e through unchanged
output.append(e)
else:
try:
x = int(e) # single int
Expand Down

0 comments on commit 96c3b90

Please sign in to comment.