MCPcopy Create free account
hub / github.com/BIT-DataLab/Edit-Banana / save_to_file

Method save_to_file

modules/text/xml_generator.py:280–304  ·  view source on GitHub ↗

保存到文件 Args: cells: 文本单元格列表 output_path: 输出文件路径(自动添加 .drawio 后缀)

(self, cells: list[TextCellData], output_path: str)

Source from the content-addressed store, hash-verified

278 )
279
280 def save_to_file(self, cells: list[TextCellData], output_path: str) -> None:
281 """
282 保存到文件
283
284 Args:
285 cells: 文本单元格列表
286 output_path: 输出文件路径(自动添加 .drawio 后缀)
287 """
288 xml_content = self.generate_xml(cells)
289 output_path = Path(output_path)
290
291 if output_path.suffix.lower() != ".drawio":
292 output_path = output_path.with_suffix(".drawio")
293
294 output_path.parent.mkdir(parents=True, exist_ok=True)
295
296 # 删除旧文件
297 if output_path.exists():
298 output_path.unlink()
299 print(f"已删除旧文件: {output_path}")
300
301 with open(output_path, "w", encoding="utf-8") as f:
302 f.write(xml_content)
303
304 print(f"已保存到: {output_path}")

Callers 1

restoreMethod · 0.95

Calls 1

generate_xmlMethod · 0.95

Tested by

no test coverage detected