parameters: (self, extract_dir)
docstring: Unpack zip `filename` to `extract_dir`
  
          Raises ``UnrecognizedFormat`` if `filename` is not a zipfile (as determined
          by ``zipfile.is_zipfile()``).
docstring_summary: Unpack zip `filename` to `extract_dir`
docstring_tokens: Unpack zip filename to extract_dir
function: def unpack_zipfile(self, extract_dir):
          """Unpack zip `filename` to `extract_dir`
  
          Raises ``UnrecognizedFormat`` if `filename` is not a zipfile (as determined
          by ``zipfile.is_zipfile()``).
          """
  
          if not zipfile.is_zipfile(self._filename):
              raise UnrecognizedFormat("%s is not a zip file" % (self._filename))
  
          print("==> Extracting files, please wait ...")
          z = zipfile.ZipFile(self._filename)
          try:
              for info in z.infolist():
                  name = info.filename
  
                  # don't extract absolute paths or ones with .. in them
                  if name.startswith('/') or '..' in name:
                      continue
  
                  target = os.path.join(extract_dir, *name.split('/'))
                  if not target:
                      continue
                  if name.endswith('/'):
                      # directory
                      self.ensure_directory(target)
                  else:
                      # file
                      data = z.read(info.filename)
                      f = open(target,'wb')
                      try:
                          f.write(data)
                      finally:
                          f.close()
                          del data
                  unix_attributes = info.external_attr >> 16
                  if unix_attributes:
                      os.chmod(target, unix_attributes)
          finally:
              z.close()
              print("==> Extraction done!")
function_tokens: def unpack_zipfile ( self , extract_dir ) : if not zipfile . is_zipfile ( self . _filename ) : raise UnrecognizedFormat ( "%s is not a zip file" % ( self . _filename ) ) print ( "==> Extracting files, please wait ..." ) z = zipfile . ZipFile ( self . _filename ) try : for info in z . infolist ( ) : name = info . filename # don't extract absolute paths or ones with .. in them if name . startswith ( '/' ) or '..' in name : continue target = os . path . join ( extract_dir , * name . split ( '/' ) ) if not target : continue if name . endswith ( '/' ) : # directory self . ensure_directory ( target ) else : # file data = z . read ( info . filename ) f = open ( target , 'wb' ) try : f . write ( data ) finally : f . close ( ) del data unix_attributes = info . external_attr >> 16 if unix_attributes : os . chmod ( target , unix_attributes ) finally : z . close ( ) print ( "==> Extraction done!" )