mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-16 09:40:07 +01:00
Python 2.7 doesn't have TemporaryDirectory
(cherry picked from commit ef81730d8a)
This commit is contained in:
@@ -971,3 +971,20 @@ def updateLicenseFiles(cfg):
|
||||
with open('LICENSE.txt', 'w') as f:
|
||||
f.write(text)
|
||||
|
||||
try:
|
||||
from tempfile import TemporaryDirectory
|
||||
except ImportError:
|
||||
from tempfile import mkdtemp
|
||||
|
||||
class TemporaryDirectory(object):
|
||||
def __init__(self, suffix='', prefix='tmp', dir=None):
|
||||
self.name = mkdtemp(suffix, prefix, dir)
|
||||
|
||||
def __enter__(self):
|
||||
return self.name
|
||||
|
||||
def __exit__(self, exc, value, tb):
|
||||
self.cleanup()
|
||||
|
||||
def cleanup(self):
|
||||
shutil.rmtree(self.name)
|
||||
|
||||
Reference in New Issue
Block a user