def update_index_unit(unit, source=True):
 if appsettings.OFFLOAD_INDEXING:
  add_index_update(unit.id, source, False)
  return
 if source:
  index = get_source_index()
  with AsyncWriter(index) as writer:
   update_source_unit_index(writer, unit)
 if unit.target:
  index = get_target_index(unit.translation.language.code)
  with AsyncWriter(index) as writer:
   update_target_unit_index(writer, unit)

def update_index_unit ( unit , source = True ) : if appsettings . OFFLOAD_INDEXING : add_index_update ( unit . id , source , False ) return if source : index = get_source_index ( ) with AsyncWriter ( index ) as writer : update_source_unit_index ( writer , unit ) if unit . target : index = get_target_index ( unit . translation . language . code ) with AsyncWriter ( index ) as writer : update_target_unit_index ( writer , unit )
adds single unit to index .