def _taradd(func, tar_file, name):
 with tempfile.NamedTemporaryFile('wb', delete=False) as temp_file:
  func(temp_file)
  temp_file.close()
  tar_file.add(temp_file.name, arcname=name)
 if os.path.isfile(temp_file.name):
  os.remove(temp_file.name)

def _taradd ( func , tar_file , name ) : with tempfile . NamedTemporaryFile ( 'wb' , delete = False ) as temp_file : func ( temp_file ) temp_file . close ( ) tar_file . add ( temp_file . name , arcname = name ) if os . path . isfile ( temp_file . name ) : os . remove ( temp_file . name )
adds elements dumped by the function func to a tar_file .