MCPcopy Create free account
hub / github.com/cdgriffith/Box / _exists

Function _exists

box/converters.py:140–153  ·  view source on GitHub ↗
(filename: str | PathLike, create: bool = False)

Source from the content-addressed store, hash-verified

138
139
140def _exists(filename: str | PathLike, create: bool = False) -> Path:
141 path = Path(filename)
142 if create:
143 try:
144 path.touch(exist_ok=True)
145 except OSError as err:
146 raise BoxError(f"Could not create file {filename} - {err}")
147 else:
148 return path
149 if not path.exists():
150 raise BoxError(f'File "{filename}" does not exist')
151 if not path.is_file():
152 raise BoxError(f"{filename} is not a file")
153 return path
154
155
156def _to_json(

Callers 11

_to_jsonFunction · 0.85
_to_yamlFunction · 0.85
_from_yamlFunction · 0.85
_to_tomlFunction · 0.85
_from_tomlFunction · 0.85
_to_msgpackFunction · 0.85
_from_msgpackFunction · 0.85
_to_toonFunction · 0.85
_from_toonFunction · 0.85
_to_csvFunction · 0.85
_from_csvFunction · 0.85

Calls 1

BoxErrorClass · 0.90

Tested by

no test coverage detected