(filename: str | PathLike, create: bool = False)
| 138 | |
| 139 | |
| 140 | def _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 | |
| 156 | def _to_json( |
no test coverage detected