X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/357027375ff8867f42ca34bcbfb5a78b5b185fc3..905f7fa0606b3218402df703ffac8bf6f825dde1:/src/search/management/commands/snippets.py?ds=inline diff --git a/src/search/management/commands/snippets.py b/src/search/management/commands/snippets.py index 40310eda1..a758317bb 100755 --- a/src/search/management/commands/snippets.py +++ b/src/search/management/commands/snippets.py @@ -10,21 +10,20 @@ from os import path from sys import stdout from django.conf import settings + class Command(BaseCommand): help = 'Reindex everything.' args = '' option_list = BaseCommand.option_list + ( make_option('-C', '--check-just-read', action='store_true', dest='check', default=False, - help='Check snippets utf-8'), + help='Check snippets utf-8'), make_option('-c', '--check', action='store_true', dest='check2', default=False, - help='Check snippets utf-8 by walking through index'), + help='Check snippets utf-8 by walking through index'), ) - def handle(self, *args, **opts): - from catalogue.models import Book - from search.index import Search + from search.index import Search, Snippets if opts['check']: sfn = glob(settings.SEARCH_INDEX+'snippets/*') @@ -46,19 +45,19 @@ class Command(BaseCommand): doc = reader.document(did) if doc and doc.get('book_id'): bkid = int(doc.get('book_id')) - #import pdb; pdb.set_trace() + # import pdb; pdb.set_trace() stdout.write("\r%d / %d" % (did, numdocs)) stdout.flush() - ss = doc.get('snippet_position') - sl = doc.get('snippet_length') + ss = doc.get('snippet_position') + sl = doc.get('snippet_length') if ss and sl: + # WTF (nie było zaimportowane) snips = Snippets(bkid) try: - txt = snips.get((ss,sl)) + txt = snips.get((ss, sl)) assert len(txt) == sl except UnicodeDecodeError, ude: stdout.write("\nerror in snippets %d\n" % bkid) raise ude stdout.write("\ndone.\n") -