diff options
author | Arfrever Frehtes Taifersar Arahesis <Arfrever.FTA@GMail.Com> | 2014-02-15 22:35:49 +0100 |
---|---|---|
committer | Arfrever Frehtes Taifersar Arahesis <Arfrever.FTA@GMail.Com> | 2014-02-15 22:35:49 +0100 |
commit | 962664bbb8564ccd3cff8072f20d56a9bdcf3043 (patch) | |
tree | f4c0de7d2b0920359057722f4dde879a031dbd0f /setuptools/svn_utils.py | |
parent | 0daefd2b07a5435b0795f3dd0c3d102352611343 (diff) | |
download | python-setuptools-git-962664bbb8564ccd3cff8072f20d56a9bdcf3043.tar.gz |
Use tempfile.TemporaryDirectory() with Python >=3.2.
Diffstat (limited to 'setuptools/svn_utils.py')
-rw-r--r-- | setuptools/svn_utils.py | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/setuptools/svn_utils.py b/setuptools/svn_utils.py index e1d336e2..d62fecd0 100644 --- a/setuptools/svn_utils.py +++ b/setuptools/svn_utils.py @@ -5,12 +5,12 @@ from distutils import log import xml.dom.pulldom
import shlex
import shutil
-import tempfile
import locale
import codecs
import unicodedata
import warnings
from setuptools.compat import unicode
+from setuptools.py31compat import TemporaryDirectory
from xml.sax.saxutils import unescape
try:
@@ -29,26 +29,6 @@ from subprocess import Popen as _Popen, PIPE as _PIPE # http://stackoverflow.com/questions/5658622/
# python-subprocess-popen-environment-path
-class TempDir(object):
- """"
- Very simple temporary directory context manager.
- Will try to delete afterward, but will also ignore OS and similar
- errors on deletion.
- """
- def __init__(self):
- self.path = None
-
- def __enter__(self):
- self.path = tempfile.mkdtemp()
- return self
-
- def __exit__(self, exctype, excvalue, exctrace):
- try:
- shutil.rmtree(self.path, True)
- except OSError: #removal errors are not the only possible
- pass
- self.path = None
-
def _run_command(args, stdout=_PIPE, stderr=_PIPE, encoding=None, stream=0):
#regarding the shell argument, see: http://bugs.python.org/issue8557
try:
@@ -256,9 +236,9 @@ class SvnInfo(object): # This is needed because .svn always creates .subversion and
# some operating systems do not handle dot directory correctly.
# Real queries in real svn repos with be concerned with it creation
- with TempDir() as tempdir:
+ with TemporaryDirectory() as tempdir:
code, data = _run_command(['svn',
- '--config-dir', tempdir.path,
+ '--config-dir', tempdir,
'--version',
'--quiet'])
@@ -282,9 +262,9 @@ class SvnInfo(object): # This is needed because .svn always creates .subversion and
# some operating systems do not handle dot directory correctly.
# Real queries in real svn repos with be concerned with it creation
- with TempDir() as tempdir:
+ with TemporaryDirectory() as tempdir:
code, data = _run_command(['svn',
- '--config-dir', tempdir.path,
+ '--config-dir', tempdir,
'info', normdir])
# Must check for some contents, as some use empty directories
|