def connectable(line, handle, element): connector = Connector(element, line) for port in element.ports(): allow = connector.allow(handle, port) if allow: return True return False
def allow(self, line, handle, item, port=None): """Glue line's handle to an item. If port is not provided, then first port is used. """ if port is None and len(item.ports()) > 0: port = item.ports()[0] adapter = Connector(item, line) return adapter.allow(handle, port)
def allow(self, sink): adapter = Connector(sink.item, self.item) return adapter and adapter.allow(self.handle, sink.port)
def allow(line, handle, item, port=None) -> bool: if port is None and len(item.ports()) > 0: port = item.ports()[0] adapter = Connector(item, line) return adapter.allow(handle, port)
def test_connection_is_allowed(diagram, block_item, proxy_port_item): connector = Connector(block_item, proxy_port_item) assert isinstance(connector, BlockProperyProxyPortConnector) assert connector.allow(proxy_port_item.handles()[0], block_item.ports()[0])