code: def tarfile_to_pif(filename, temp_root_dir='', verbose=0):
      
      temp_dir = temp_root_dir + str(uuid.uuid4())
      os.makedirs(temp_dir)
      try:
          tar = tarfile.open(filename, 'r')
          tar.extractall(path=temp_dir)
          tar.close()
          for i in os.listdir(temp_dir):
              cur_dir = temp_dir + '/' + i
              if os.path.isdir(cur_dir):
                  return directory_to_pif(cur_dir, verbose=verbose)
          return directory_to_pif(temp_dir, verbose=verbose)
      finally:
          shutil.rmtree(temp_dir)
docs: Process a tar file that contains DFT data.
  
      Input:
          filename - String, Path to the file to process.
          temp_root_dir - String, Directory in which to save temporary files. Defaults to working directory.
          verbose - int, How much status messages to print
  
      Output:
          pif - ChemicalSystem, Results and settings of
              the DFT calculation in pif format