X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/cad95a5f21346628d1dffa3b50ffa8f38baa5972..2efc949091b037dc8e9d43b37788eb30105b11e9:/src/search/management/commands/reindex_pictures.py 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)