Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

This approach works, but still produces a TempDir objects instead of …

…paths.
  • Loading branch information...
commit c2a546f6ed79fa60510f579e69b51cfbf5fac2cf 1 parent bf82b39
@jaraco authored
Showing with 6 additions and 7 deletions.
  1. +6 −7 path.py
View
13 path.py
@@ -1101,18 +1101,15 @@ def startfile(self):
os.startfile(self)
return self
-class tempdir(path):
+class TempDir(path):
"""
A temporary directory via tempfile.mkdtemp, and constructed with the
same parameters.
"""
- def __new__(cls, *args, **kwargs):
- dirname = tempfile.mkdtemp(*args, **kwargs)
- return super(tempdir, cls).__new__(cls, dirname)
-
- def __init__(self, *args, **kwargs):
- pass
+ @classmethod
+ def new(cls, *args, **kwargs):
+ return TempDir(tempfile.mkdtemp(*args, **kwargs))
def __enter__(self):
return self
@@ -1120,3 +1117,5 @@ def __enter__(self):
def __exit__(self, exc_type, exc_value, traceback):
if not exc_value:
self.rmtree()
+
+tempdir = TempDir.new
Please sign in to comment.
Something went wrong with that request. Please try again.