MCPcopy Index your code
hub / github.com/bhowiebkr/PyFlowGraph / _convert_data_format

Method _convert_data_format

src/core/node_graph.py:325–365  ·  view source on GitHub ↗

Convert deserialize format to PasteNodesCommand format.

(self, data)

Source from the content-addressed store, hash-verified

323 self._is_pasting = False
324
325 def _convert_data_format(self, data):
326 """Convert deserialize format to PasteNodesCommand format."""
327 clipboard_data = {
328 'nodes': [],
329 'groups': [],
330 'connections': []
331 }
332
333 # Convert nodes - preserve ALL properties
334 for node_data in data.get('nodes', []):
335 converted_node = {
336 'id': node_data.get('uuid', node_data.get('id', '')), # Try 'uuid' first, then 'id'
337 'title': node_data.get('title', 'Unknown'),
338 'description': node_data.get('description', ''),
339 'code': node_data.get('code', ''),
340 'pos': node_data.get('pos', [0, 0]),
341 'size': node_data.get('size', [200, 150]),
342 'colors': node_data.get('colors', {}),
343 'gui_state': node_data.get('gui_state', {}),
344 'gui_code': node_data.get('gui_code', ''),
345 'gui_get_values_code': node_data.get('gui_get_values_code', ''),
346 'is_reroute': node_data.get('is_reroute', False)
347 }
348 clipboard_data['nodes'].append(converted_node)
349
350 # Convert groups
351 for group_data in data.get('groups', []):
352 # Groups use their full serialized data for pasting
353 clipboard_data['groups'].append(group_data)
354
355 # Convert connections
356 for conn_data in data.get('connections', []):
357 converted_conn = {
358 'output_node_id': conn_data.get('start_node_uuid', ''),
359 'input_node_id': conn_data.get('end_node_uuid', ''),
360 'output_pin_name': conn_data.get('start_pin_name', ''),
361 'input_pin_name': conn_data.get('end_pin_name', '')
362 }
363 clipboard_data['connections'].append(converted_conn)
364
365 return clipboard_data
366
367 def serialize(self):
368 """Serializes all nodes, connections, and groups."""

Calls

no outgoing calls