(self)
| 158 | self.is_script = is_script |
| 159 | |
| 160 | def prepare(self): |
| 161 | self.file_path = os.path.expanduser(self.file_path) |
| 162 | if not os.path.isfile(self.file_path): |
| 163 | raise ValueError(f'File {self.file_path} does not exist') |
| 164 | self.size = os.path.getsize(self.file_path) |
| 165 | if not self.mime_type: |
| 166 | mt = mimetypes.guess_type(self.file_path) |
| 167 | if isinstance(mt, tuple) and mt[0]: |
| 168 | self.mime_type = mt[0] |
| 169 | |
| 170 | @contextlib.contextmanager |
| 171 | def open(self): |