def rebuild(self): memory = TranslationMemory() data = list(memory.searcher.documents()) memory.empty() with memory.writer() as writer: for entry in data: writer.add_document(**entry)
def handle(self, *args, **options): """Translation memory cleanup.""" memory = TranslationMemory() if options['all']: memory.empty() elif options['origin'] or options['category']: memory.delete(options['origin'], options['category']) else: raise CommandError('Please specify what you want to delete')