MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeWiki / write_component_source

Method write_component_source

codewiki/mcp/workspace.py:73–83  ·  view source on GitHub ↗

Write a single component's source code to the ``sources/`` dir.

(
        self,
        component_id: str,
        source: str,
        language: str = "",
    )

Source from the content-addressed store, hash-verified

71 p.write_text(json.dumps(data, indent=2, ensure_ascii=False), encoding="utf-8")
72 return p
73
74 def write_component_source(
75 self,
76 component_id: str,
77 source: str,
78 language: str = "",
79 ) -> Path:
80 """Write a single component's source code to the ``sources/`` dir."""
81 p = self.root / "sources" / _safe_filename(component_id)
82 header = f"// Component: {component_id}\n// Language: {language}\n"
83 p.write_text(header + source, encoding="utf-8")
84 return p
85
86 # -- readers ----------------------------------------------------------

Callers 1

Calls 1

_safe_filenameFunction · 0.85

Tested by

no test coverage detected