Clean the package layout

This commit is contained in:
Valentin Niess
2020-03-29 16:07:53 +02:00
parent f18d9d5537
commit f8a4c10644
15 changed files with 25 additions and 22 deletions

View File

@@ -0,0 +1,24 @@
from contextlib import contextmanager as contextmanager
import os
import tempfile
from .fs import remove_tree
from .log import debug
__all__ = ['TemporaryDirectory']
@contextmanager
def TemporaryDirectory():
'''Create a temporary directory (Python 2 wrapper)
'''
tmpdir = tempfile.mkdtemp(prefix='python-appimage-')
debug('MKDIR', tmpdir)
pwd = os.getcwd()
os.chdir(tmpdir)
try:
yield tmpdir
finally:
os.chdir(pwd)
remove_tree(tmpdir)