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

Method _node_to_flow

src/data/flow_format.py:45–103  ·  view source on GitHub ↗

Convert a single node to .md format.

(self, node: Dict[str, Any])

Source from the content-addressed store, hash-verified

43 return flow_content
44
45 def _node_to_flow(self, node: Dict[str, Any]) -> str:
46 """Convert a single node to .md format."""
47 uuid = node.get("uuid", "")
48 title = node.get("title", "")
49 description = node.get("description", "")
50
51 content = f"## Node: {title} (ID: {uuid})\n\n"
52
53 # Add description if available
54 if description.strip():
55 cleaned_description = self._clean_description(description)
56 content += f"{cleaned_description}\n\n"
57
58 # Metadata section
59 metadata = {
60 "uuid": uuid,
61 "title": title,
62 "pos": node.get("pos", [0, 0]),
63 "size": node.get("size", [200, 150])
64 }
65
66 # Include is_reroute flag if this is a reroute node
67 if node.get("is_reroute", False):
68 metadata["is_reroute"] = True
69
70 # Always include colors (even if empty) for consistency
71 metadata["colors"] = node.get("colors", {})
72
73 # Always include gui_state (even if empty) for consistency
74 metadata["gui_state"] = node.get("gui_state", {})
75
76 content += "### Metadata\n\n"
77 content += "```json\n"
78 content += json.dumps(metadata, indent=2)
79 content += "\n```\n\n"
80
81 # Logic section
82 content += "### Logic\n\n"
83 content += "```python\n"
84 content += node.get("code", "")
85 content += "\n```\n\n"
86
87 # GUI Definition (include even if empty for consistency)
88 gui_code = node.get("gui_code", "")
89 if gui_code.strip(): # Only include section if there's actual content
90 content += "### GUI Definition\n\n"
91 content += "```python\n"
92 content += gui_code
93 content += "\n```\n\n"
94
95 # GUI State Handler (include even if empty for consistency)
96 gui_get_values_code = node.get("gui_get_values_code", "")
97 if gui_get_values_code.strip(): # Only include section if there's actual content
98 content += "### GUI State Handler\n\n"
99 content += "```python\n"
100 content += gui_get_values_code
101 content += "\n```\n\n"
102

Callers 1

data_to_markdownMethod · 0.95

Calls 1

_clean_descriptionMethod · 0.95

Tested by

no test coverage detected