X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/cad95a5f21346628d1dffa3b50ffa8f38baa5972..db6ce7eb0542012566e8632cd8db45d647b1d652:/src/search/management/commands/reindex_pictures.py?ds=sidebyside diff --git a/src/search/management/commands/reindex_pictures.py b/src/search/management/commands/reindex_pictures.py index bb6b50fcc..8505189a1 100644 --- a/src/search/management/commands/reindex_pictures.py +++ b/src/search/management/commands/reindex_pictures.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # @@ -7,8 +6,6 @@ import traceback from django.core.management.base import BaseCommand -from optparse import make_option - def query_yes_no(question, default="yes"): """Ask a yes/no question via raw_input() and return their answer. @@ -44,21 +41,21 @@ def query_yes_no(question, default="yes"): class Command(BaseCommand): help = 'Reindex pictures.' - args = '' - option_list = BaseCommand.option_list + ( - make_option('-n', '--picture-id', action='store_true', dest='picture_id', default=False, - help='picture id instead of slugs'), - ) + def add_arguments(self, parser): + self.add_argument( + '-n', '--picture-id', action='store_true', dest='picture_id', + default=False, help='picture id instead of slugs') + self.add_argument('slug/id', nargs='*', metavar='slug/id') - def handle(self, *args, **opts): + def handle(self, **opts): from picture.models import Picture from search.index import Index idx = Index() - if args: + if opts['args']: pictures = [] - for a in args: + for a in opts['args']: if opts['picture_id']: pictures += Picture.objects.filter(id=int(a)).all() else: @@ -68,7 +65,7 @@ class Command(BaseCommand): while pictures: try: p = pictures[0] - print p.slug + print(p.slug) idx.index_picture(p) idx.index.commit() pictures.pop(0)