parameters: (filename, extract_dir, progress_filter=default_filter)
docstring: Unpack zip `filename` to `extract_dir`
  
      Raises ``UnrecognizedFormat`` if `filename` is not a zipfile (as determined
      by ``zipfile.is_zipfile()``).  See ``unpack_archive()`` for an explanation
      of the `progress_filter` argument.
docstring_summary: Unpack zip `filename` to `extract_dir`
docstring_tokens: Unpack zip filename to extract_dir
function: def unpack_zipfile(filename, extract_dir, progress_filter=default_filter):
      """Unpack zip `filename` to `extract_dir`
  
      Raises ``UnrecognizedFormat`` if `filename` is not a zipfile (as determined
      by ``zipfile.is_zipfile()``).  See ``unpack_archive()`` for an explanation
      of the `progress_filter` argument.
      """
  
      if not zipfile.is_zipfile(filename):
          raise UnrecognizedFormat("%s is not a zip file" % (filename,))
  
      with zipfile.ZipFile(filename) as z:
          for info in z.infolist():
              name = info.filename
  
              # don't extract absolute paths or ones with .. in them
              if name.startswith('/') or '..' in name.split('/'):
                  continue
  
              target = os.path.join(extract_dir, *name.split('/'))
              target = progress_filter(name, target)
              if not target:
                  continue
              if name.endswith('/'):
                  # directory
                  ensure_directory(target)
              else:
                  # file
                  ensure_directory(target)
                  data = z.read(info.filename)
                  with open(target, 'wb') as f:
                      f.write(data)
              unix_attributes = info.external_attr >> 16
              if unix_attributes:
                  os.chmod(target, unix_attributes)
function_tokens: def unpack_zipfile ( filename , extract_dir , progress_filter = default_filter ) : if not zipfile . is_zipfile ( filename ) : raise UnrecognizedFormat ( "%s is not a zip file" % ( filename , ) ) with zipfile . ZipFile ( filename ) as z : for info in z . infolist ( ) : name = info . filename # don't extract absolute paths or ones with .. in them if name . startswith ( '/' ) or '..' in name . split ( '/' ) : continue target = os . path . join ( extract_dir , * name . split ( '/' ) ) target = progress_filter ( name , target ) if not target : continue if name . endswith ( '/' ) : # directory ensure_directory ( target ) else : # file ensure_directory ( target ) data = z . read ( info . filename ) with open ( target , 'wb' ) as f : f . write ( data ) unix_attributes = info . external_attr >> 16 if unix_attributes : os . chmod ( target , unix_attributes )