Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/setuptools/py31compat.py @ 5:9b1c78e6ba9c draft default tip
"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
| author | shellac |
|---|---|
| date | Mon, 01 Jun 2020 08:59:25 -0400 |
| parents | 79f47841a781 |
| children |
comparison
equal
deleted
inserted
replaced
| 4:79f47841a781 | 5:9b1c78e6ba9c |
|---|---|
| 1 __all__ = [] | |
| 2 | |
| 3 __metaclass__ = type | |
| 4 | |
| 5 | |
| 6 try: | |
| 7 # Python >=3.2 | |
| 8 from tempfile import TemporaryDirectory | |
| 9 except ImportError: | |
| 10 import shutil | |
| 11 import tempfile | |
| 12 | |
| 13 class TemporaryDirectory: | |
| 14 """ | |
| 15 Very simple temporary directory context manager. | |
| 16 Will try to delete afterward, but will also ignore OS and similar | |
| 17 errors on deletion. | |
| 18 """ | |
| 19 | |
| 20 def __init__(self, **kwargs): | |
| 21 self.name = None # Handle mkdtemp raising an exception | |
| 22 self.name = tempfile.mkdtemp(**kwargs) | |
| 23 | |
| 24 def __enter__(self): | |
| 25 return self.name | |
| 26 | |
| 27 def __exit__(self, exctype, excvalue, exctrace): | |
| 28 try: | |
| 29 shutil.rmtree(self.name, True) | |
| 30 except OSError: # removal errors are not the only possible | |
| 31 pass | |
| 32 self.name = None |
