From 0049f9e0c2cd84849a3009054a2f4a642022c394 Mon Sep 17 00:00:00 2001 From: ilvalle Date: Thu, 11 Dec 2014 14:27:39 +0100 Subject: [PATCH] updated _extractall (python 2.4 support was dropped) --- gluon/fileutils.py | 57 +--------------------------------------------- 1 file changed, 1 insertion(+), 56 deletions(-) diff --git a/gluon/fileutils.py b/gluon/fileutils.py index 121ad99e..98ec3096 100644 --- a/gluon/fileutils.py +++ b/gluon/fileutils.py @@ -193,62 +193,7 @@ def cleanpath(path): def _extractall(filename, path='.', members=None): - # FIXME: this should be dropped because python 2.4 support was dropped - if not hasattr(tarfile.TarFile, 'extractall'): - from tarfile import ExtractError - - class TarFile(tarfile.TarFile): - - def extractall(self, path='.', members=None): - """Extract all members from the archive to the current working - directory and set owner, modification time and permissions on - directories afterwards. `path' specifies a different directory - to extract to. `members' is optional and must be a subset of the - list returned by getmembers(). - """ - - directories = [] - if members is None: - members = self - for tarinfo in members: - if tarinfo.isdir(): - - # Extract directory with a safe mode, so that - # all files below can be extracted as well. - - try: - os.makedirs(os.path.join(path, - tarinfo.name), 0777) - except EnvironmentError: - pass - directories.append(tarinfo) - else: - self.extract(tarinfo, path) - - # Reverse sort directories. - - directories.sort(lambda a, b: cmp(a.name, b.name)) - directories.reverse() - - # Set correct owner, mtime and filemode on directories. - - for tarinfo in directories: - path = os.path.join(path, tarinfo.name) - try: - self.chown(tarinfo, path) - self.utime(tarinfo, path) - self.chmod(tarinfo, path) - except ExtractError, e: - if self.errorlevel > 1: - raise - else: - self._dbg(1, 'tarfile: %s' % e) - - _cls = TarFile - else: - _cls = tarfile.TarFile - - tar = _cls(filename, 'r') + tar = tarfile.TarFile(filename, 'r') ret = tar.extractall(path, members) tar.close() return ret