Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
formatc1702 committed Jun 7, 2023
1 parent 908f627 commit a5eac13
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/wireviz/wireviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ def alternate_type(): # flip between connector and cable/arrow
if index_item == 0: # list started with a cable, no connector to join on left side
from_name, from_pin = (None, None)
else:
from_name, from_pin = get_single_key_and_value(connection_set[index_entry][index_item-1])
from_name, from_pin = get_single_key_and_value(entry[index_item-1])
via_name, via_pin = (designator, item[designator])
if index_item == len(entry) - 1: # list ends with a cable, no connector to join on right side
to_name, to_pin = (None, None)
else:
to_name, to_pin = get_single_key_and_value(connection_set[index_entry][index_item+1])
to_name, to_pin = get_single_key_and_value(entry[index_item+1])
harness.connect(from_name, from_pin, via_name, via_pin, to_name, to_pin)

elif is_arrow(designator):
Expand All @@ -246,9 +246,11 @@ def alternate_type(): # flip between connector and cable/arrow
elif index_item == len(entry) - 1: # list ends with an arrow
raise Exception('An arrow cannot be at the end of a connection set')

from_name, from_pin = get_single_key_and_value(connection_set[index_entry][index_item-1])
# self.connectors[from_name].pins.index(from_pin)
# import pudb; pu.db
from_name, from_pin = get_single_key_and_value(entry[index_item-1])
via_name, via_pin = (designator, None)
to_name, to_pin = get_single_key_and_value(connection_set[index_entry][index_item+1])
to_name, to_pin = get_single_key_and_value(entry[index_item+1])
if '-' in designator: # mate pin by pin
harness.add_mate_pin(from_name, from_pin, to_name, to_pin, designator)
elif '=' in designator and index_entry == 0: # mate two connectors as a whole
Expand Down

0 comments on commit a5eac13

Please sign in to comment.