| 213 | raise PipxError("Internal Error: PipxMetadata is corrupt, cannot write.") |
| 214 | |
| 215 | def write(self) -> None: |
| 216 | self._validate_before_write() |
| 217 | try: |
| 218 | with open(self.venv_dir / PIPX_INFO_FILENAME, "w", encoding="utf-8") as pipx_metadata_fh: |
| 219 | json.dump( |
| 220 | self.to_dict(), |
| 221 | pipx_metadata_fh, |
| 222 | indent=4, |
| 223 | sort_keys=True, |
| 224 | cls=JsonEncoderHandlesPath, |
| 225 | ) |
| 226 | except OSError: |
| 227 | _LOGGER.warning( |
| 228 | pipx_wrap( |
| 229 | f""" |
| 230 | {hazard} Unable to write {PIPX_INFO_FILENAME} to |
| 231 | {self.venv_dir}. This may cause future pipx operations |
| 232 | involving {self.venv_dir.name} to fail or behave |
| 233 | incorrectly. |
| 234 | """, |
| 235 | subsequent_indent=" " * 4, |
| 236 | ) |
| 237 | ) |
| 238 | |
| 239 | def read(self, verbose: bool = False) -> None: |
| 240 | try: |