Changeset 107147 in webkit


Ignore:
Timestamp:
Feb 8, 2012 4:10:04 PM (12 years ago)
Author:
abarth@webkit.org
Message:

Don't re-implement ZipFile.extractall
https://bugs.webkit.org/show_bug.cgi?id=78173

Reviewed by Eric Seidel.

We can use ZipFile.extractall now that we don't support Python 2.5.

  • Scripts/webkitpy/common/system/autoinstall.py:

(AutoInstaller._extract_targz):
(AutoInstaller._unzip):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r107145 r107147  
     12012-02-08  Adam Barth  <abarth@webkit.org>
     2
     3        Don't re-implement ZipFile.extractall
     4        https://bugs.webkit.org/show_bug.cgi?id=78173
     5
     6        Reviewed by Eric Seidel.
     7
     8        We can use ZipFile.extractall now that we don't support Python 2.5.
     9
     10        * Scripts/webkitpy/common/system/autoinstall.py:
     11        (AutoInstaller._extract_targz):
     12        (AutoInstaller._unzip):
     13
    1142012-02-08  Adam Barth  <abarth@webkit.org>
    215
  • trunk/Tools/Scripts/webkitpy/common/system/autoinstall.py

    r107136 r107147  
    260260        return target_path
    261261
    262     # This is a replacement for ZipFile.extractall(), which is
    263     # available in Python 2.6 but not in earlier versions.
    264     def _extract_all(self, zip_file, target_dir):
    265         self._log_transfer("Extracting zip file...", zip_file, target_dir)
    266 
    267         # This is helpful for debugging purposes.
    268         _log.debug("Listing zip file contents...")
    269         for name in zip_file.namelist():
    270             _log.debug('    * "%s"' % name)
    271 
    272         for name in zip_file.namelist():
    273             path = os.path.join(target_dir, name)
    274             self._log_transfer("Extracting...", name, path)
    275 
    276             if not os.path.basename(path):
    277                 # Then the path ends in a slash, so it is a directory.
    278                 self._create_directory(path)
    279                 continue
    280             # Otherwise, it is a file.
    281 
    282             try:
    283                 # We open this file w/o encoding, as we're reading/writing
    284                 # the raw byte-stream from the zip file.
    285                 outfile = open(path, 'wb')
    286             except IOError, err:
    287                 # Not all zip files seem to list the directories explicitly,
    288                 # so try again after creating the containing directory.
    289                 _log.debug("Got IOError: retrying after creating directory...")
    290                 dir = os.path.dirname(path)
    291                 self._create_directory(dir)
    292                 outfile = open(path, 'wb')
    293 
    294             try:
    295                 outfile.write(zip_file.read(name))
    296             finally:
    297                 outfile.close()
    298 
    299262    def _unzip(self, path, scratch_dir):
    300263        # zipfile.extractall() extracts to a path without the
     
    314277
    315278        try:
    316             self._extract_all(zip_file, scratch_dir)
     279            zip_file.extractall(scratch_dir)
    317280        finally:
    318281            zip_file.close()
Note: See TracChangeset for help on using the changeset viewer.