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,)))
 try:
  tarobj.chown = (lambda *args: None)
  for member in tarobj:
   name = member.name
   if ((not name.startswith('/')) and ('..' not in name.split('/'))):
    prelim_dst = os.path.join(extract_dir, *name.split('/'))
    while ((member is not None) and (member.islnk() or member.issym())):
     linkpath = member.linkname
     if member.issym():
      linkpath = posixpath.join(posixpath.dirname(member.name), 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:
       tarobj._extract_member(member, final_dst)
      except tarfile.ExtractError:
       pass
  return True
 finally:
  tarobj.close()

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 , ) ) ) try : tarobj . chown = ( lambda * args : None ) for member in tarobj : name = member . name if ( ( not name . startswith ( '/' ) ) and ( '..' not in name . split ( '/' ) ) ) : prelim_dst = os . path . join ( extract_dir , * name . split ( '/' ) ) while ( ( member is not None ) and ( member . islnk ( ) or member . issym ( ) ) ) : linkpath = member . linkname if member . issym ( ) : linkpath = posixpath . join ( posixpath . dirname ( member . name ) , 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 : tarobj . _extract_member ( member , final_dst ) except tarfile . ExtractError : pass return True finally : tarobj . close ( )
unpack tar/tar .