MCPcopy
hub / github.com/InternLM/MindSearch / ensure_file

Method ensure_file

docker/msdl/config.py:16–24  ·  view source on GitHub ↗

Ensure the file exists, create if it doesn't

(file_path, default_content="")

Source from the content-addressed store, hash-verified

14
15 @staticmethod
16 def ensure_file(file_path, default_content=""):
17 """Ensure the file exists, create if it doesn't"""
18 path = Path(file_path)
19 if not path.parent.exists():
20 FileSystemManager.ensure_dir(path.parent)
21 if not path.exists():
22 with open(path, "w") as f:
23 f.write(default_content)
24 return path
25
26
27# Get the directory where the script is located

Callers 1

config.pyFile · 0.80

Calls 1

ensure_dirMethod · 0.80

Tested by

no test coverage detected