distinguish between dict and list connectors in error message

This commit is contained in:
Hans Baier 2023-04-11 14:10:07 +07:00
parent cfaba189c4
commit 750f8c41b9
1 changed files with 5 additions and 1 deletions

View File

@ -168,7 +168,11 @@ class ConnectorManager:
if pn.isdigit(): if pn.isdigit():
pn = int(pn) pn = int(pn)
assert conn in self.connector_table, f"No connector named '{conn}' is available" assert conn in self.connector_table, f"No connector named '{conn}' is available"
assert pn in self.connector_table[conn], f"There is no pin '{pn}' on connector '{conn}'" conn_entry = self.connector_table[conn]
if isinstance(conn_entry, dict):
assert pn in conn_entry, f"There is no pin '{pn}' on connector '{conn}'"
else:
assert pn < len(conn_entry), f"There is no pin with number '{pn}' on connector '{conn}', maximum is {len(conn_entry)-1}"
conn_pn = self.connector_table[conn][pn] conn_pn = self.connector_table[conn][pn]
if ":" in conn_pn: if ":" in conn_pn:
conn_pn = self.resolve_identifiers([conn_pn])[0] conn_pn = self.resolve_identifiers([conn_pn])[0]