@contextlib.contextmanager
def tempdir(**kwargs):
    argdict = kwargs.copy()
    if 'dir' not in argdict:
        argdict['dir'] = CONF.tempdir
    tmpdir = tempfile.mkdtemp(**argdict)
    try:
        yield tmpdir
    finally:
        try:
            shutil.rmtree(tmpdir)
        except __HOLE__ as e:
            LOG.error(_('Could not remove tmpdir: %s'), str(e))
dataset/ETHPy150Open openstack/ec2-api/ec2api/utils.py/tempdir