[Port / PortList] raise PortError on missing port name
This commit is contained in:
parent
b44c962e07
commit
ffbe15c465
2 changed files with 49 additions and 0 deletions
|
|
@ -328,6 +328,9 @@ class PortList(metaclass=ABCMeta):
|
|||
duplicates = (set(self.ports.keys()) - set(mapping.keys())) & set(mapping.values())
|
||||
if duplicates:
|
||||
raise PortError(f'Unrenamed ports would be overwritten: {duplicates}')
|
||||
missing = set(mapping) - set(self.ports)
|
||||
if missing:
|
||||
raise PortError(f'Ports to rename were not found: {missing}')
|
||||
|
||||
for kk, vv in mapping.items():
|
||||
if vv is None or vv != kk:
|
||||
|
|
@ -395,6 +398,14 @@ class PortList(metaclass=ABCMeta):
|
|||
Raises:
|
||||
`PortError` if the ports are not properly aligned.
|
||||
"""
|
||||
if not connections:
|
||||
raise PortError('Must provide at least one port connection')
|
||||
missing_a = set(connections) - set(self.ports)
|
||||
if missing_a:
|
||||
raise PortError(f'Connection source ports were not found: {missing_a}')
|
||||
missing_b = set(connections.values()) - set(self.ports)
|
||||
if missing_b:
|
||||
raise PortError(f'Connection destination ports were not found: {missing_b}')
|
||||
a_names, b_names = list(zip(*connections.items(), strict=True))
|
||||
a_ports = [self.ports[pp] for pp in a_names]
|
||||
b_ports = [self.ports[pp] for pp in b_names]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue