diff options
| author | Maxime Turcotte <maxime.turcotte@savoirfairelinux.com> | 2014-06-17 19:07:54 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-06-19 08:54:59 -0400 |
| commit | 9996158db467f9bef8243fcc36dc3602570e3613 (patch) | |
| tree | bf3b5cb36e3083b84de592d6e9da4fd2d131c5f4 /django | |
| parent | 63670a474c14b1989f1a3f4ee7fd0fbacb5a764a (diff) | |
Fixed #22835 -- Deprecated NoArgsCommand.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/sessions/management/commands/clearsessions.py | 6 | ||||
| -rw-r--r-- | django/contrib/staticfiles/management/commands/collectstatic.py | 12 | ||||
| -rw-r--r-- | django/core/management/base.py | 8 | ||||
| -rw-r--r-- | django/core/management/commands/diffsettings.py | 6 | ||||
| -rw-r--r-- | django/core/management/commands/flush.py | 6 | ||||
| -rw-r--r-- | django/core/management/commands/inspectdb.py | 6 | ||||
| -rw-r--r-- | django/core/management/commands/makemessages.py | 6 | ||||
| -rw-r--r-- | django/core/management/commands/shell.py | 6 | ||||
| -rw-r--r-- | django/core/management/commands/sqlflush.py | 6 | ||||
| -rw-r--r-- | django/core/management/commands/syncdb.py | 6 | ||||
| -rw-r--r-- | django/core/management/commands/validate.py | 4 |
11 files changed, 41 insertions, 31 deletions
diff --git a/django/contrib/sessions/management/commands/clearsessions.py b/django/contrib/sessions/management/commands/clearsessions.py index fa0dad31c3..23e7f143e0 100644 --- a/django/contrib/sessions/management/commands/clearsessions.py +++ b/django/contrib/sessions/management/commands/clearsessions.py @@ -1,13 +1,13 @@ from importlib import import_module from django.conf import settings -from django.core.management.base import NoArgsCommand +from django.core.management.base import BaseCommand -class Command(NoArgsCommand): +class Command(BaseCommand): help = "Can be run as a cronjob or directly to clean out expired sessions (only with the database backend at the moment)." - def handle_noargs(self, **options): + def handle(self, **options): engine = import_module(settings.SESSION_ENGINE) try: engine.SessionStore.clear_expired() diff --git a/django/contrib/staticfiles/management/commands/collectstatic.py b/django/contrib/staticfiles/management/commands/collectstatic.py index 714f36e1de..2d2413e808 100644 --- a/django/contrib/staticfiles/management/commands/collectstatic.py +++ b/django/contrib/staticfiles/management/commands/collectstatic.py @@ -4,7 +4,8 @@ import os from collections import OrderedDict from django.core.files.storage import FileSystemStorage -from django.core.management.base import CommandError, NoArgsCommand +from django.core.management.base import CommandError, BaseCommand +from django.core.management.color import no_style from django.utils.encoding import smart_text from django.utils.six.moves import input @@ -12,7 +13,7 @@ from django.contrib.staticfiles.finders import get_finders from django.contrib.staticfiles.storage import staticfiles_storage -class Command(NoArgsCommand): +class Command(BaseCommand): """ Command that allows to copy or symlink static files from different locations to the settings.STATIC_ROOT. @@ -21,12 +22,13 @@ class Command(NoArgsCommand): requires_system_checks = False def __init__(self, *args, **kwargs): - super(NoArgsCommand, self).__init__(*args, **kwargs) + super(BaseCommand, self).__init__(*args, **kwargs) self.copied_files = [] self.symlinked_files = [] self.unmodified_files = [] self.post_processed_files = [] self.storage = staticfiles_storage + self.style = no_style() try: self.storage.path('') except NotImplementedError: @@ -79,7 +81,7 @@ class Command(NoArgsCommand): """ Perform the bulk of the work of collectstatic. - Split off from handle_noargs() to facilitate testing. + Split off from handle() to facilitate testing. """ if self.symlink and not self.local: raise CommandError("Can't symlink to a remote destination.") @@ -130,7 +132,7 @@ class Command(NoArgsCommand): 'post_processed': self.post_processed_files, } - def handle_noargs(self, **options): + def handle(self, **options): self.set_options(**options) message = ['\n'] diff --git a/django/core/management/base.py b/django/core/management/base.py index 99997059dc..2f8664f128 100644 --- a/django/core/management/base.py +++ b/django/core/management/base.py @@ -603,6 +603,14 @@ class NoArgsCommand(BaseCommand): """ args = '' + def __init__(self): + warnings.warn( + "NoArgsCommand class is deprecated and will be removed in Django 2.0. " + "Use BaseCommand instead, which takes no arguments by default.", + RemovedInDjango20Warning + ) + super(NoArgsCommand, self).__init__() + def handle(self, *args, **options): if args: raise CommandError("Command doesn't accept any arguments") diff --git a/django/core/management/commands/diffsettings.py b/django/core/management/commands/diffsettings.py index cb31894aa8..ac724fca3f 100644 --- a/django/core/management/commands/diffsettings.py +++ b/django/core/management/commands/diffsettings.py @@ -1,4 +1,4 @@ -from django.core.management.base import NoArgsCommand +from django.core.management.base import BaseCommand def module_to_dict(module, omittable=lambda k: k.startswith('_')): @@ -6,7 +6,7 @@ def module_to_dict(module, omittable=lambda k: k.startswith('_')): return dict((k, repr(v)) for k, v in module.__dict__.items() if not omittable(k)) -class Command(NoArgsCommand): +class Command(BaseCommand): help = """Displays differences between the current settings.py and Django's default settings. Settings that don't appear in the defaults are followed by "###".""" @@ -18,7 +18,7 @@ class Command(NoArgsCommand): help='Display all settings, regardless of their value. ' 'Default values are prefixed by "###".') - def handle_noargs(self, **options): + def handle(self, **options): # Inspired by Postfix's "postconf -n". from django.conf import settings, global_settings diff --git a/django/core/management/commands/flush.py b/django/core/management/commands/flush.py index fc2256d2e0..ccbc47bd90 100644 --- a/django/core/management/commands/flush.py +++ b/django/core/management/commands/flush.py @@ -4,14 +4,14 @@ from importlib import import_module from django.apps import apps from django.db import connections, router, transaction, DEFAULT_DB_ALIAS from django.core.management import call_command -from django.core.management.base import NoArgsCommand, CommandError +from django.core.management.base import BaseCommand, CommandError from django.core.management.color import no_style from django.core.management.sql import sql_flush, emit_post_migrate_signal from django.utils.six.moves import input from django.utils import six -class Command(NoArgsCommand): +class Command(BaseCommand): help = ('Removes ALL DATA from the database, including data added during ' 'migrations. Unmigrated apps will also have their initial_data ' 'fixture reloaded. Does not achieve a "fresh install" state.') @@ -26,7 +26,7 @@ class Command(NoArgsCommand): dest='load_initial_data', default=True, help='Tells Django not to load any initial data after database synchronization.') - def handle_noargs(self, **options): + def handle(self, **options): database = options.get('database') connection = connections[database] verbosity = options.get('verbosity') diff --git a/django/core/management/commands/inspectdb.py b/django/core/management/commands/inspectdb.py index 783dcc06f3..1eecf29dc6 100644 --- a/django/core/management/commands/inspectdb.py +++ b/django/core/management/commands/inspectdb.py @@ -4,11 +4,11 @@ from collections import OrderedDict import keyword import re -from django.core.management.base import NoArgsCommand, CommandError +from django.core.management.base import BaseCommand, CommandError from django.db import connections, DEFAULT_DB_ALIAS -class Command(NoArgsCommand): +class Command(BaseCommand): help = "Introspects the database tables in the given database and outputs a Django model module." requires_system_checks = False @@ -20,7 +20,7 @@ class Command(NoArgsCommand): default=DEFAULT_DB_ALIAS, help='Nominates a database to ' 'introspect. Defaults to using the "default" database.') - def handle_noargs(self, **options): + def handle(self, **options): try: for line in self.handle_inspection(options): self.stdout.write("%s\n" % line) diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py index 7f3f24428d..120847bd5d 100644 --- a/django/core/management/commands/makemessages.py +++ b/django/core/management/commands/makemessages.py @@ -9,7 +9,7 @@ import sys from itertools import dropwhile import django -from django.core.management.base import CommandError, NoArgsCommand +from django.core.management.base import CommandError, BaseCommand from django.core.management.utils import (handle_extensions, find_command, popen_wrapper) from django.utils.encoding import force_str @@ -162,7 +162,7 @@ def write_pot_file(potfile, msgs): fp.write(msgs) -class Command(NoArgsCommand): +class Command(BaseCommand): help = ("Runs over the entire source tree of the current directory and " "pulls out all strings marked for translation. It creates (or updates) a message " "file in the conf/locale (in the django tree) or locale (for projects and " @@ -210,7 +210,7 @@ class Command(NoArgsCommand): parser.add_argument('--keep-pot', action='store_true', dest='keep_pot', default=False, help="Keep .pot file after making messages. Useful when debugging.") - def handle_noargs(self, *args, **options): + def handle(self, *args, **options): locale = options.get('locale') exclude = options.get('exclude') self.domain = options.get('domain') diff --git a/django/core/management/commands/shell.py b/django/core/management/commands/shell.py index d0c03030af..d8bded0673 100644 --- a/django/core/management/commands/shell.py +++ b/django/core/management/commands/shell.py @@ -1,9 +1,9 @@ import os -from django.core.management.base import NoArgsCommand +from django.core.management.base import BaseCommand -class Command(NoArgsCommand): +class Command(BaseCommand): help = "Runs a Python interactive interpreter. Tries to use IPython or bpython, if one of them is available." requires_system_checks = False shells = ['ipython', 'bpython'] @@ -60,7 +60,7 @@ class Command(NoArgsCommand): pass raise ImportError - def handle_noargs(self, **options): + def handle(self, **options): try: if options['plain']: # Don't bother loading IPython, because the user wants plain Python. diff --git a/django/core/management/commands/sqlflush.py b/django/core/management/commands/sqlflush.py index 48bc693611..a94ac79b67 100644 --- a/django/core/management/commands/sqlflush.py +++ b/django/core/management/commands/sqlflush.py @@ -1,11 +1,11 @@ from __future__ import unicode_literals -from django.core.management.base import NoArgsCommand +from django.core.management.base import BaseCommand from django.core.management.sql import sql_flush from django.db import connections, DEFAULT_DB_ALIAS -class Command(NoArgsCommand): +class Command(BaseCommand): help = "Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed." output_transaction = True @@ -16,5 +16,5 @@ class Command(NoArgsCommand): help='Nominates a database to print the SQL for. Defaults to the ' '"default" database.') - def handle_noargs(self, **options): + def handle(self, **options): return '\n'.join(sql_flush(self.style, connections[options['database']], only_django=True)) diff --git a/django/core/management/commands/syncdb.py b/django/core/management/commands/syncdb.py index 52b9dde956..b89ad62c3e 100644 --- a/django/core/management/commands/syncdb.py +++ b/django/core/management/commands/syncdb.py @@ -4,12 +4,12 @@ from django.apps import apps from django.contrib.auth import get_user_model from django.db import DEFAULT_DB_ALIAS from django.core.management import call_command -from django.core.management.base import NoArgsCommand +from django.core.management.base import BaseCommand from django.utils.deprecation import RemovedInDjango19Warning from django.utils.six.moves import input -class Command(NoArgsCommand): +class Command(BaseCommand): help = "Deprecated - use 'migrate' instead." def add_arguments(self, parser): @@ -20,7 +20,7 @@ class Command(NoArgsCommand): parser.add_argument('--database', default=DEFAULT_DB_ALIAS, help='Nominates a database to synchronize. Defaults to the "default" database.') - def handle_noargs(self, **options): + def handle(self, **options): warnings.warn("The syncdb command will be removed in Django 1.9", RemovedInDjango19Warning) call_command("migrate", **options) diff --git a/django/core/management/commands/validate.py b/django/core/management/commands/validate.py index 490fe6c26f..9383746f1f 100644 --- a/django/core/management/commands/validate.py +++ b/django/core/management/commands/validate.py @@ -10,7 +10,7 @@ from django.utils.deprecation import RemovedInDjango19Warning class Command(CheckCommand): help = 'Deprecated. Use "check" command instead. ' + CheckCommand.help - def handle_noargs(self, **options): + def handle(self, **options): warnings.warn('"validate" has been deprecated in favor of "check".', RemovedInDjango19Warning) - super(Command, self).handle_noargs(**options) + super(Command, self).handle(**options) |
