| 41 | |
| 42 | @attr.s(frozen=True) |
| 43 | class Tempdir(object): |
| 44 | path = attr.ib(converter=_realpath) # type: str |
| 45 | symlink = attr.ib(default=None) # type: Optional[str] |
| 46 | |
| 47 | def join(self, *components): |
| 48 | # type: (*str) -> str |
| 49 | return os.path.join(self.path, *components) |
| 50 | |
| 51 | def safe_remove(self): |
| 52 | # type: () -> None |
| 53 | if self.symlink: |
| 54 | safe_delete(self.symlink) |
| 55 | safe_rmtree(self.path) |
| 56 | |
| 57 | def __str__(self): |
| 58 | # type: () -> str |
| 59 | return self.path |
| 60 | |
| 61 | |
| 62 | @attr.s(frozen=True) |