MCPcopy Create free account
hub / github.com/ResearAI/AutoFigure / write_text_file

Function write_text_file

autofigure/utils/file_utils.py:45–69  ·  view source on GitHub ↗

Write text content to a file. Args: path: File path content: Text content to write encoding: Text encoding Returns: True on success, False on failure

(
    path: Union[str, Path],
    content: str,
    encoding: str = "utf-8"
)

Source from the content-addressed store, hash-verified

43
44
45def write_text_file(
46 path: Union[str, Path],
47 content: str,
48 encoding: str = "utf-8"
49) -> bool:
50 """
51 Write text content to a file.
52
53 Args:
54 path: File path
55 content: Text content to write
56 encoding: Text encoding
57
58 Returns:
59 True on success, False on failure
60 """
61 try:
62 path = Path(path)
63 path.parent.mkdir(parents=True, exist_ok=True)
64 with open(path, "w", encoding=encoding) as f:
65 f.write(content)
66 return True
67 except Exception as e:
68 print(f"[file_utils] Failed to write file {path}: {e}")
69 return False
70
71
72def get_temp_path(suffix: str = "", prefix: str = "autofigure_") -> Path:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected