code: 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
  
file_path: catboost/contrib/python/setuptools/py2/setuptools/archive_util.py
imports: import zipfile
  import tarfile
  import os
  import shutil
  import posixpath
  import contextlib
  from distutils.errors import DistutilsError
  from pkg_resources import ensure_directory
label_desc: Use image node_id 5 for calling a global function with example usage: unpack_tarfile(filename, extract_dir, progress_filter) and returns: True