MCPcopy Create free account
hub / github.com/bhowiebkr/PyFlowGraph / execute

Method execute

src/commands/connection_commands.py:68–103  ·  view source on GitHub ↗

Create the connection and add to graph.

(self)

Source from the content-addressed store, hash-verified

66 }
67
68 def execute(self) -> bool:
69 """Create the connection and add to graph."""
70 try:
71 # Import here to avoid circular imports
72 from core.connection import Connection
73
74 # Validate connection is still possible
75 if not self._validate_connection():
76 return False
77
78 # Remove any existing connection to the input pin (end_pin)
79 existing_connection = None
80 for conn in self.node_graph.connections:
81 if hasattr(conn, 'end_pin') and conn.end_pin == self.input_pin:
82 existing_connection = conn
83 break
84
85 if existing_connection:
86 self.node_graph.removeItem(existing_connection)
87 self.node_graph.connections.remove(existing_connection)
88
89 # Create new connection
90 self.created_connection = Connection(self.output_pin, self.input_pin)
91
92 # Add to graph
93 self.node_graph.addItem(self.created_connection)
94 self.node_graph.connections.append(self.created_connection)
95
96 # Note: Pin connections are already added in Connection constructor
97
98 self._mark_executed()
99 return True
100
101 except Exception as e:
102 print(f"Failed to create connection: {e}")
103 return False
104
105 def undo(self) -> bool:
106 """Remove the created connection."""

Callers 1

executeMethod · 0.95

Calls 4

_validate_connectionMethod · 0.95
ConnectionClass · 0.90
removeMethod · 0.80
_mark_executedMethod · 0.80

Tested by

no test coverage detected