Remove the root of the payload. This function requires some extra care due to the root directory being a cached property.
(self, *, ignore_errors: bool = True)
| 402 | return Path(tempfile.mkdtemp(prefix="payload-")) |
| 403 | |
| 404 | def remove(self, *, ignore_errors: bool = True) -> None: |
| 405 | """Remove the root of the payload. |
| 406 | |
| 407 | This function requires some extra care due to the root directory being a cached property. |
| 408 | """ |
| 409 | root = getattr(self, "root", None) |
| 410 | if root is None: |
| 411 | return |
| 412 | shutil.rmtree(root, ignore_errors=ignore_errors) |
| 413 | # Now we drop the cached value so next access will recreate if desired |
| 414 | try: |
| 415 | delattr(self, "root") |
| 416 | except Exception: |
| 417 | # delattr on a cached_property may raise on some versions / edge cases |
| 418 | pass |
| 419 | |
| 420 | def prepare(self) -> None: |
| 421 | """Prepares the payload. |
no outgoing calls