def connect(self, plug, edge=None): if not self.isConnectedTo(plug) or not plug.isOutput(): edge = plug.getConnection(self) if not edge: edge = baseEdge.Edge("_".join([self.name, plug.name]), inputPlug=plug, outputPlug=self) self.connectionAdded.emit(edge) return edge edge.connect(plug, self) self.connectionAdded.emit(edge) return edge
def connect(self, plug): """Creates a connection between to plugs, a input can only have one input so current connections is cleared before creating the new connection :param plug: BasePlug instance :return: Edge """ if plug.isInput() or self.getConnection(plug): return edge = baseEdge.Edge(self.name + "_" + plug.name, inputPlug=self, outputPlug=plug) self.dirty = True self.connectionAdded.emit(edge) return edge
def testIsConnected(self): edge3 = baseEdge.Edge("testEdg2") self.assertTrue(self.edge.isConnected(self.inputPlug, self.outputPlug)) self.assertFalse(edge3.isConnected(self.inputPlug, self.outputPlug))
def setUp(self): self.inputPlug = plug.InputPlug("inputPlug1") self.outputPlug = plug.OutputPlug("outputPlug1") self.edge = baseEdge.Edge("testEdge1", inputPlug=self.inputPlug, outputPlug=self.outputPlug) self.edge2 = baseEdge.Edge("testEdg2", inputPlug=self.inputPlug, outputPlug=self.outputPlug)
def testEquality(self): edge3 = baseEdge.Edge("testEdg2") self.assertEquals(self.edge, self.edge2) self.assertNotEquals(self.edge, edge3)