summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2014-09-29 21:56:12 -0400
committerJason R. Coombs <jaraco@jaraco.com>2014-09-29 21:56:12 -0400
commit3a59f306bda5ceceb9c52ae94ab59ebb5863818f (patch)
tree8f4d43a7e273450debc1a228e22c775af5a72f92
parent76416f3adbab68b5f7c3a513bc9013f8d08db1c8 (diff)
downloadpython-setuptools-bitbucket-3a59f306bda5ceceb9c52ae94ab59ebb5863818f.tar.gz
Remove Python 2.5 compatibility methods for zipfiles
-rw-r--r--setuptools/tests/environment.py53
1 files changed, 1 insertions, 52 deletions
diff --git a/setuptools/tests/environment.py b/setuptools/tests/environment.py
index 476d280a..bbc7fd35 100644
--- a/setuptools/tests/environment.py
+++ b/setuptools/tests/environment.py
@@ -10,57 +10,6 @@ import unicodedata
from subprocess import Popen as _Popen, PIPE as _PIPE
-def _extract(self, member, path=None, pwd=None):
- """for zipfile py2.5 borrowed from cpython"""
- if not isinstance(member, zipfile.ZipInfo):
- member = self.getinfo(member)
-
- if path is None:
- path = os.getcwd()
-
- return _extract_member(self, member, path, pwd)
-
-
-def _extract_from_zip(self, name, dest_path):
- dest_file = open(dest_path, 'wb')
- try:
- dest_file.write(self.read(name))
- finally:
- dest_file.close()
-
-
-def _extract_member(self, member, targetpath, pwd):
- """for zipfile py2.5 borrowed from cpython"""
- # build the destination pathname, replacing
- # forward slashes to platform specific separators.
- # Strip trailing path separator, unless it represents the root.
- if (targetpath[-1:] in (os.path.sep, os.path.altsep)
- and len(os.path.splitdrive(targetpath)[1]) > 1):
- targetpath = targetpath[:-1]
-
- # don't include leading "/" from file name if present
- if member.filename[0] == '/':
- targetpath = os.path.join(targetpath, member.filename[1:])
- else:
- targetpath = os.path.join(targetpath, member.filename)
-
- targetpath = os.path.normpath(targetpath)
-
- # Create all upper directories if necessary.
- upperdirs = os.path.dirname(targetpath)
- if upperdirs and not os.path.exists(upperdirs):
- os.makedirs(upperdirs)
-
- if member.filename[-1] == '/':
- if not os.path.isdir(targetpath):
- os.mkdir(targetpath)
- return targetpath
-
- _extract_from_zip(self, member.filename, targetpath)
-
- return targetpath
-
-
def _remove_dir(target):
#on windows this seems to a problem
@@ -92,7 +41,7 @@ class ZippedEnvironment(unittest.TestCase):
try:
zip_file = zipfile.ZipFile(self.datafile)
for files in zip_file.namelist():
- _extract(zip_file, files, self.temp_dir)
+ zip_file.extract(files, self.temp_dir)
finally:
if zip_file:
zip_file.close()