Merge pull request #1410 from trabucayre/improve_connectors

Improve connectors
This commit is contained in:
enjoy-digital 2022-08-30 15:34:55 +02:00 committed by GitHub
commit ea8ba57eab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 1 deletions

View File

@ -132,6 +132,12 @@ def _resource_type(resource):
class ConnectorManager:
def __init__(self, connectors):
self.connector_table = dict()
self.add_connector(connectors)
def add_connector(self, connectors):
if isinstance(connectors, tuple):
connectors = [connectors]
for connector in connectors:
cit = iter(connector)
conn_name = next(cit)
@ -162,7 +168,10 @@ class ConnectorManager:
if pn.isdigit():
pn = int(pn)
r.append(self.connector_table[conn][pn])
conn_pn = self.connector_table[conn][pn]
if ":" in conn_pn:
conn_pn = self.resolve_identifiers([conn_pn])[0]
r.append(conn_pn)
else:
r.append(identifier)
@ -193,6 +202,9 @@ class ConstraintManager:
def add_extension(self, io):
self.available.extend(io)
def add_connector(self, connectors):
self.connector_manager.add_connector(connectors)
def request(self, name, number=None, loose=False):
resource = _lookup(self.available, name, number, loose)
if resource is None:
@ -356,6 +368,9 @@ class GenericPlatform:
def add_extension(self, *args, **kwargs):
return self.constraint_manager.add_extension(*args, **kwargs)
def add_connector(self, *args, **kwargs):
self.constraint_manager.add_connector(*args, **kwargs)
def finalize(self, fragment, *args, **kwargs):
if self.finalized:
raise ConstraintError("Already finalized")