| 1 | # SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <[email protected]> |
| 3 | |
| 4 | import os |
| 5 | |
| 6 | |
| 7 | class LinkGuard: |
| 8 | def __init__(self, src, dst): |
| 9 | self.src = src |
| 10 | self.dst = dst |
| 11 | |
| 12 | def __enter__(self): |
| 13 | os.symlink(self.src, self.dst) |
| 14 | |
| 15 | def __exit__(self, type, val, tb): |
| 16 | os.unlink(self.dst) |