[PorList] Error if multiple ports are renamed to the same name
This commit is contained in:
parent
8d50f497f1
commit
6a7b3b2259
2 changed files with 23 additions and 0 deletions
|
|
@ -331,6 +331,10 @@ class PortList(metaclass=ABCMeta):
|
|||
missing = set(mapping) - set(self.ports)
|
||||
if missing:
|
||||
raise PortError(f'Ports to rename were not found: {missing}')
|
||||
renamed_targets = [vv for vv in mapping.values() if vv is not None]
|
||||
duplicate_targets = {vv for vv in renamed_targets if renamed_targets.count(vv) > 1}
|
||||
if duplicate_targets:
|
||||
raise PortError(f'Renamed ports would collide: {duplicate_targets}')
|
||||
|
||||
for kk, vv in mapping.items():
|
||||
if vv is None or vv != kk:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue