MCPcopy Create free account
hub / github.com/MAC-VO/MAC-VO / SandboxFile

Class SandboxFile

Utility/Sandbox.py:36–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35
36class SandboxFile:
37 def __init__(self, root_path: Path, name: str, mode: str):
38 self.file = Path(root_path, name)
39 self.mode = mode
40 self.fp = None
41
42 def __enter__(self):
43 self.fp = open(self.file, self.mode)
44 return self.fp
45
46 def __exit__(self, exc_type, exc_val, exc_tb):
47 if self.fp is None:
48 return
49
50 self.fp.close()
51 if exc_type is not None:
52 Logger.write("warn", f"File {self.file} with mode {self.mode} fails.",)
53 return True
54
55
56class Sandbox:

Callers 1

openMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected