parameters: (filename, extract_dir, progress_filter=default_filter)
docstring: Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
  
      Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined
      by ``tarfile.open()``).  See ``unpack_archive()`` for an explanation
      of the `progress_filter` argument.
docstring_summary: Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
docstring_tokens: Unpack tar / tar . gz / tar . bz2 filename to extract_dir
function: def unpack_tarfile(filename, extract_dir, progress_filter=default_filter):
      """Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
  
      Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined
      by ``tarfile.open()``).  See ``unpack_archive()`` for an explanation
      of the `progress_filter` argument.
      """
      try:
          tarobj = tarfile.open(filename)
      except tarfile.TarError:
          raise UnrecognizedFormat(
              "%s is not a compressed or uncompressed tar file" % (filename,)
          )
      with contextlib.closing(tarobj):
          # don't do any chowning!
          tarobj.chown = lambda *args: None
          for member in tarobj:
              name = member.name
              # don't extract absolute paths or ones with .. in them
              if not name.startswith('/') and '..' not in name.split('/'):
                  prelim_dst = os.path.join(extract_dir, *name.split('/'))
  
                  # resolve any links and to extract the link targets as normal
                  # files
                  while member is not None and (
                          member.islnk() or member.issym()):
                      linkpath = member.linkname
                      if member.issym():
                          base = posixpath.dirname(member.name)
                          linkpath = posixpath.join(base, linkpath)
                          linkpath = posixpath.normpath(linkpath)
                      member = tarobj._getmember(linkpath)
  
                  if member is not None and (member.isfile() or member.isdir()):
                      final_dst = progress_filter(name, prelim_dst)
                      if final_dst:
                          if final_dst.endswith(os.sep):
                              final_dst = final_dst[:-1]
                          try:
                              # XXX Ugh
                              tarobj._extract_member(member, final_dst)
                          except tarfile.ExtractError:
                              # chown/chmod/mkfifo/mknode/makedev failed
                              pass
          return True
function_tokens: def unpack_tarfile ( filename , extract_dir , progress_filter = default_filter ) : try : tarobj = tarfile . open ( filename ) except tarfile . TarError : raise UnrecognizedFormat ( "%s is not a compressed or uncompressed tar file" % ( filename , ) ) with contextlib . closing ( tarobj ) : # don't do any chowning! tarobj . chown = lambda * args : None for member in tarobj : name = member . name # don't extract absolute paths or ones with .. in them if not name . startswith ( '/' ) and '..' not in name . split ( '/' ) : prelim_dst = os . path . join ( extract_dir , * name . split ( '/' ) ) # resolve any links and to extract the link targets as normal # files while member is not None and ( member . islnk ( ) or member . issym ( ) ) : linkpath = member . linkname if member . issym ( ) : base = posixpath . dirname ( member . name ) linkpath = posixpath . join ( base , linkpath ) linkpath = posixpath . normpath ( linkpath ) member = tarobj . _getmember ( linkpath ) if member is not None and ( member . isfile ( ) or member . isdir ( ) ) : final_dst = progress_filter ( name , prelim_dst ) if final_dst : if final_dst . endswith ( os . sep ) : final_dst = final_dst [ : - 1 ] try : # XXX Ugh tarobj . _extract_member ( member , final_dst ) except tarfile . ExtractError : # chown/chmod/mkfifo/mknode/makedev failed pass return True