mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-24 16:10:02 -06:00
b431e9b684
Python 2 had old style and new style classes. Python 3 has only new style classes. There is no point to subclass from object any more. See: https://pagure.io/freeipa/issue/7715 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
24 lines
499 B
Python
24 lines
499 B
Python
#
|
|
# Copyright (C) 2014 FreeIPA Contributors see COPYING for license
|
|
#
|
|
|
|
import errno
|
|
import shutil
|
|
import tempfile
|
|
|
|
|
|
class TemporaryDirectory:
|
|
def __init__(self, root):
|
|
self.root = root
|
|
|
|
def __enter__(self):
|
|
self.name = tempfile.mkdtemp(dir=self.root)
|
|
return self.name
|
|
|
|
def __exit__(self, exc_type, exc_value, traceback):
|
|
try:
|
|
shutil.rmtree(self.name)
|
|
except OSError as e:
|
|
if e.errno != errno.ENOENT:
|
|
raise
|