Look-up mated connectors before mate processing (#358)
Symptom reported in #355: Unable to connect an arrow (mate) to pins higher than 1 without failing: ValueError: X is not in list Bug: The code processing mates used a mix of repeated connector look-ups and local connector variables, and one variable was used before it was assigned the correct value. Fix: The local connector variables are now both assigned initially before processing each mate, and used when processing instead of repeated connector look-ups.
This commit is contained in:
parent
a89d04d8ca
commit
557122c4a3
@ -595,6 +595,7 @@ class Harness:
|
|||||||
typecheck("tweak.append", self.tweak.append, str)
|
typecheck("tweak.append", self.tweak.append, str)
|
||||||
dot.body.append(self.tweak.append)
|
dot.body.append(self.tweak.append)
|
||||||
|
|
||||||
|
# TODO: All code below until "return dot" must be moved above all tweak processing!
|
||||||
for mate in self.mates:
|
for mate in self.mates:
|
||||||
if mate.shape[0] == "<" and mate.shape[-1] == ">":
|
if mate.shape[0] == "<" and mate.shape[-1] == ">":
|
||||||
dir = "both"
|
dir = "both"
|
||||||
@ -613,29 +614,18 @@ class Harness:
|
|||||||
raise Exception(f"{mate} is an unknown mate")
|
raise Exception(f"{mate} is an unknown mate")
|
||||||
|
|
||||||
from_connector = self.connectors[mate.from_name]
|
from_connector = self.connectors[mate.from_name]
|
||||||
if (
|
to_connector = self.connectors[mate.to_name]
|
||||||
isinstance(mate, MatePin)
|
if isinstance(mate, MatePin) and from_connector.style != "simple":
|
||||||
and self.connectors[mate.from_name].style != "simple"
|
|
||||||
):
|
|
||||||
from_pin_index = from_connector.pins.index(mate.from_pin)
|
from_pin_index = from_connector.pins.index(mate.from_pin)
|
||||||
from_port_str = f":p{from_pin_index+1}r"
|
from_port_str = f":p{from_pin_index+1}r"
|
||||||
else: # MateComponent or style == 'simple'
|
else: # MateComponent or style == 'simple'
|
||||||
from_port_str = ""
|
from_port_str = ""
|
||||||
if (
|
if isinstance(mate, MatePin) and to_connector.style != "simple":
|
||||||
isinstance(mate, MatePin)
|
|
||||||
and self.connectors[mate.to_name].style != "simple"
|
|
||||||
):
|
|
||||||
to_pin_index = to_connector.pins.index(mate.to_pin)
|
to_pin_index = to_connector.pins.index(mate.to_pin)
|
||||||
to_port_str = (
|
to_port_str = f":p{to_pin_index+1}l"
|
||||||
f":p{to_pin_index+1}l"
|
|
||||||
if isinstance(mate, MatePin)
|
|
||||||
and self.connectors[mate.to_name].style != "simple"
|
|
||||||
else ""
|
|
||||||
)
|
|
||||||
else: # MateComponent or style == 'simple'
|
else: # MateComponent or style == 'simple'
|
||||||
to_port_str = ""
|
to_port_str = ""
|
||||||
code_from = f"{mate.from_name}{from_port_str}:e"
|
code_from = f"{mate.from_name}{from_port_str}:e"
|
||||||
to_connector = self.connectors[mate.to_name]
|
|
||||||
code_to = f"{mate.to_name}{to_port_str}:w"
|
code_to = f"{mate.to_name}{to_port_str}:w"
|
||||||
|
|
||||||
dot.attr("edge", color=color, style="dashed", dir=dir)
|
dot.attr("edge", color=color, style="dashed", dir=dir)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user