From 94e6c2bbea0c80a26980db20a8f435f072577f3a Mon Sep 17 00:00:00 2001 From: Tim Heap Date: Wed, 23 Mar 2016 17:26:32 +1100 Subject: [PATCH] Use add_arguments over deprecated option_list --- .../wagtailcore/management/commands/fixtree.py | 11 ++++------- .../commands/publish_scheduled_pages.py | 14 ++++---------- .../management/commands/update_index.py | 15 ++++----------- 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/wagtail/wagtailcore/management/commands/fixtree.py b/wagtail/wagtailcore/management/commands/fixtree.py index 1d4d7e1c41..65e7b60a2e 100644 --- a/wagtail/wagtailcore/management/commands/fixtree.py +++ b/wagtail/wagtailcore/management/commands/fixtree.py @@ -1,6 +1,5 @@ import functools import operator -from optparse import make_option from django.core.management.base import BaseCommand from django.db import models @@ -12,13 +11,11 @@ from wagtail.wagtailcore.models import Page class Command(BaseCommand): help = "Checks for data integrity errors on the page tree, and fixes them where possible." - base_options = ( - make_option( + + def add_arguments(self, parser): + parser.add_argument( '--noinput', action='store_false', dest='interactive', default=True, - help='If provided, any fixes requiring user interaction will be skipped.' - ), - ) - option_list = BaseCommand.option_list + base_options + help='If provided, any fixes requiring user interaction will be skipped.') def numberlist_to_string(self, numberlist): # Converts a list of numbers into a string diff --git a/wagtail/wagtailcore/management/commands/publish_scheduled_pages.py b/wagtail/wagtailcore/management/commands/publish_scheduled_pages.py index 8bd9c84c83..4fdbec39f0 100644 --- a/wagtail/wagtailcore/management/commands/publish_scheduled_pages.py +++ b/wagtail/wagtailcore/management/commands/publish_scheduled_pages.py @@ -1,7 +1,6 @@ from __future__ import print_function import json -from optparse import make_option from django.core.management.base import BaseCommand from django.utils import dateparse, timezone @@ -21,15 +20,10 @@ def revision_date_expired(r): class Command(BaseCommand): - option_list = BaseCommand.option_list + ( - make_option( - '--dryrun', - action='store_true', - dest='dryrun', - default=False, - help='Dry run -- don\'t change anything.' - ), - ) + def add_arguments(self, parser): + parser.add_argument( + '--dryrun', action='store_true', dest='dryrun', default=False, + help="Dry run -- dont't change anything.") def handle(self, *args, **options): dryrun = False diff --git a/wagtail/wagtailsearch/management/commands/update_index.py b/wagtail/wagtailsearch/management/commands/update_index.py index 9420189d77..6ae2db2b33 100644 --- a/wagtail/wagtailsearch/management/commands/update_index.py +++ b/wagtail/wagtailsearch/management/commands/update_index.py @@ -1,5 +1,3 @@ -from optparse import make_option - from django.conf import settings from django.core.management.base import BaseCommand from django.db import transaction @@ -57,15 +55,10 @@ class Command(BaseCommand): self.stdout.write(backend_name + ": Finishing rebuild") rebuilder.finish() - option_list = BaseCommand.option_list + ( - make_option( - '--backend', - action='store', - dest='backend_name', - default=None, - help="Specify a backend to update", - ), - ) + def add_arguments(self, parser): + parser.add_argument( + '--backend', action='store', dest='backend_name', default=None, + help="Specify a backend to update") def handle(self, **options): # Get object list