def handle(self, *args, **options): # Optimize index if options['optimize']: self.optimize_index() return # Optionally rebuild indices from scratch if options['clean']: clean_indexes() # Open writer source_writer = get_source_index().writer() target_writers = {} try: # Process all units for unit in self.iterate_units(**options): lang = unit.translation.language.code # Lazy open writer if lang not in target_writers: target_writers[lang] = get_target_index(lang).writer() # Update target index if unit.translation: update_target_unit_index(target_writers[lang], unit) # Update source index update_source_unit_index(source_writer, unit) finally: # Close all writers source_writer.commit() for code in target_writers: target_writers[code].commit()
def handle(self, *args, **options): # Optionally rebuild indices from scratch if options["clean"]: clean_indexes() # Open writer source_writer = get_source_index().writer() target_writers = {} try: # Process all units for unit in self.iterate_units(*args, **options): lang = unit.translation.language.code # Lazy open writer if lang not in target_writers: target_writers[lang] = get_target_index(lang).writer() # Update target index if unit.translation: update_target_unit_index(target_writers[lang], unit) # Update source index update_source_unit_index(source_writer, unit) finally: # Close all writers source_writer.commit() for lang in target_writers: target_writers[lang].commit()
def handle(self, *args, **options): # Optionally rebuild indices from scratch if options['clean']: create_source_index() for lang in Language.objects.have_translation(): create_target_index(lang=lang.code) # Open writer source_writer = BufferedWriter(get_source_index()) target_writers = {} try: # Process all units for unit in self.iterate_units(*args, **options): lang = unit.translation.language.code # Lazy open writer if lang not in target_writers: target_writers[lang] = BufferedWriter( get_target_index(lang) ) # Update target index if unit.translation: update_target_unit_index(target_writers[lang], unit) # Update source index update_source_unit_index(source_writer, unit) finally: # Close all writers source_writer.close() for lang in target_writers: target_writers[lang].close()
def handle(self, *args, **options): # Optionally rebuild indices from scratch if options['clean']: create_source_index() for lang in Language.objects.have_translation(): create_target_index(lang=lang.code) # Open writer source_writer = get_source_index().writer() target_writers = {} try: # Process all units for unit in self.iterate_units(*args, **options): lang = unit.translation.language.code # Lazy open writer if lang not in target_writers: target_writers[lang] = get_target_index(lang).writer() # Update target index if unit.translation: update_target_unit_index(target_writers[lang], unit) # Update source index update_source_unit_index(source_writer, unit) finally: # Close all writers source_writer.commit() for lang in target_writers: target_writers[lang].commit()
def optimize_index(self): """Optimize index structures""" index = get_source_index() index.optimize() languages = Language.objects.have_translation() for lang in languages: index = get_target_index(lang.code) index.optimize()
def optimize_index(self): """Optimizes index structures""" index = get_source_index() index.optimize() languages = Language.objects.have_translation() for lang in languages: index = get_target_index(lang.code) index.optimize()