-
commit 80718040e4370e721b6b3c38654760eab70dac0e
Author: Claude Paroz <claude@2xlibre.net>
Date: Thu Oct 13 22:16:11 2011 +0200
Remove duplicate defaults in management commands
diff --git a/django/core/management/commands/createcachetable.py b/django/core/management/commands/createcachetable.py
index 90172b6..a6628a0 100644
a
|
b
|
class Command(LabelCommand):
|
18 | 18 | requires_model_validation = False |
19 | 19 | |
20 | 20 | def handle_label(self, tablename, **options): |
21 | | alias = options.get('database', DEFAULT_DB_ALIAS) |
| 21 | alias = options.get('database') |
22 | 22 | connection = connections[alias] |
23 | 23 | fields = ( |
24 | 24 | # "key" is a reserved word in MySQL, so use "cache_key" instead. |
-
diff --git a/django/core/management/commands/dbshell.py b/django/core/management/commands/dbshell.py
index a6b5427..7465920 100644
a
|
b
|
class Command(BaseCommand):
|
16 | 16 | requires_model_validation = False |
17 | 17 | |
18 | 18 | def handle(self, **options): |
19 | | connection = connections[options.get('database', DEFAULT_DB_ALIAS)] |
| 19 | connection = connections[options.get('database')] |
20 | 20 | try: |
21 | 21 | connection.client.runshell() |
22 | 22 | except OSError: |
-
diff --git a/django/core/management/commands/dumpdata.py b/django/core/management/commands/dumpdata.py
index 0426d19..1622929 100644
a
|
b
|
class Command(BaseCommand):
|
30 | 30 | def handle(self, *app_labels, **options): |
31 | 31 | from django.db.models import get_app, get_apps, get_model |
32 | 32 | |
33 | | format = options.get('format','json') |
34 | | indent = options.get('indent',None) |
35 | | using = options.get('database', DEFAULT_DB_ALIAS) |
36 | | excludes = options.get('exclude',[]) |
37 | | show_traceback = options.get('traceback', False) |
38 | | use_natural_keys = options.get('use_natural_keys', False) |
39 | | use_base_manager = options.get('use_base_manager', False) |
| 33 | format = options.get('format') |
| 34 | indent = options.get('indent') |
| 35 | using = options.get('database') |
| 36 | excludes = options.get('exclude') |
| 37 | show_traceback = options.get('traceback') |
| 38 | use_natural_keys = options.get('use_natural_keys') |
| 39 | use_base_manager = options.get('use_base_manager') |
40 | 40 | |
41 | 41 | excluded_apps = set() |
42 | 42 | excluded_models = set() |
-
diff --git a/django/core/management/commands/flush.py b/django/core/management/commands/flush.py
index 0fe2779..6d0f14e 100644
a
|
b
|
class Command(NoArgsCommand):
|
23 | 23 | 're-executed, and the initial_data fixture will be re-installed.') |
24 | 24 | |
25 | 25 | def handle_noargs(self, **options): |
26 | | db = options.get('database', DEFAULT_DB_ALIAS) |
| 26 | db = options.get('database') |
27 | 27 | connection = connections[db] |
28 | | verbosity = int(options.get('verbosity', 1)) |
| 28 | verbosity = int(options.get('verbosity')) |
29 | 29 | interactive = options.get('interactive') |
30 | 30 | |
31 | 31 | self.style = no_style() |
-
diff --git a/django/core/management/commands/inspectdb.py b/django/core/management/commands/inspectdb.py
index 90272db..76073c7 100644
a
|
b
|
class Command(NoArgsCommand):
|
25 | 25 | raise CommandError("Database inspection isn't supported for the currently selected database backend.") |
26 | 26 | |
27 | 27 | def handle_inspection(self, options): |
28 | | connection = connections[options.get('database', DEFAULT_DB_ALIAS)] |
| 28 | connection = connections[options.get('database')] |
29 | 29 | |
30 | 30 | table2model = lambda table_name: table_name.title().replace('_', '').replace(' ', '').replace('-', '') |
31 | 31 | |
-
diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py
index 7b0e30f..356e2d0 100644
a
|
b
|
class Command(BaseCommand):
|
34 | 34 | ) |
35 | 35 | |
36 | 36 | def handle(self, *fixture_labels, **options): |
37 | | using = options.get('database', DEFAULT_DB_ALIAS) |
| 37 | using = options.get('database') |
38 | 38 | |
39 | 39 | connection = connections[using] |
40 | 40 | self.style = no_style() |
41 | 41 | |
42 | | verbosity = int(options.get('verbosity', 1)) |
43 | | show_traceback = options.get('traceback', False) |
| 42 | verbosity = int(options.get('verbosity')) |
| 43 | show_traceback = options.get('traceback') |
44 | 44 | |
45 | 45 | # commit is a stealth option - it isn't really useful as |
46 | 46 | # a command line option, but it can be useful when invoking |
-
diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py
index 2e693e7..a0d2af5 100644
a
|
b
|
class Command(BaseRunserverCommand):
|
140 | 140 | Serves admin media like old-school (deprecation pending). |
141 | 141 | """ |
142 | 142 | handler = super(Command, self).get_handler(*args, **options) |
143 | | return AdminMediaHandler(handler, options.get('admin_media_path', '')) |
| 143 | return AdminMediaHandler(handler, options.get('admin_media_path')) |
-
diff --git a/django/core/management/commands/sql.py b/django/core/management/commands/sql.py
index 582bc8e..59b2e77 100644
a
|
b
|
class Command(AppCommand):
|
16 | 16 | output_transaction = True |
17 | 17 | |
18 | 18 | def handle_app(self, app, **options): |
19 | | return u'\n'.join(sql_create(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8') |
| 19 | return u'\n'.join(sql_create(app, self.style, connections[options.get('database')])).encode('utf-8') |
-
diff --git a/django/core/management/commands/sqlall.py b/django/core/management/commands/sqlall.py
index 8f3a38e..ab702bf 100644
a
|
b
|
class Command(AppCommand):
|
16 | 16 | output_transaction = True |
17 | 17 | |
18 | 18 | def handle_app(self, app, **options): |
19 | | return u'\n'.join(sql_all(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8') |
| 19 | return u'\n'.join(sql_all(app, self.style, connections[options.get('database')])).encode('utf-8') |
-
diff --git a/django/core/management/commands/sqlclear.py b/django/core/management/commands/sqlclear.py
index c7e3a5e..b8f4913 100644
a
|
b
|
class Command(AppCommand):
|
16 | 16 | output_transaction = True |
17 | 17 | |
18 | 18 | def handle_app(self, app, **options): |
19 | | return u'\n'.join(sql_delete(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8') |
| 19 | return u'\n'.join(sql_delete(app, self.style, connections[options.get('database')])).encode('utf-8') |
-
diff --git a/django/core/management/commands/sqlcustom.py b/django/core/management/commands/sqlcustom.py
index d206b04..6a98456 100644
a
|
b
|
class Command(AppCommand):
|
16 | 16 | output_transaction = True |
17 | 17 | |
18 | 18 | def handle_app(self, app, **options): |
19 | | return u'\n'.join(sql_custom(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8') |
| 19 | return u'\n'.join(sql_custom(app, self.style, connections[options.get('database')])).encode('utf-8') |
-
diff --git a/django/core/management/commands/sqlflush.py b/django/core/management/commands/sqlflush.py
index 004f0a5..19054fb 100644
a
|
b
|
class Command(NoArgsCommand):
|
16 | 16 | output_transaction = True |
17 | 17 | |
18 | 18 | def handle_noargs(self, **options): |
19 | | return u'\n'.join(sql_flush(self.style, connections[options.get('database', DEFAULT_DB_ALIAS)], only_django=True)).encode('utf-8') |
| 19 | return u'\n'.join(sql_flush(self.style, connections[options.get('database')], only_django=True)).encode('utf-8') |
-
diff --git a/django/core/management/commands/sqlindexes.py b/django/core/management/commands/sqlindexes.py
index c889f03..bf55b0d 100644
a
|
b
|
class Command(AppCommand):
|
17 | 17 | output_transaction = True |
18 | 18 | |
19 | 19 | def handle_app(self, app, **options): |
20 | | return u'\n'.join(sql_indexes(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8') |
| 20 | return u'\n'.join(sql_indexes(app, self.style, connections[options.get('database')])).encode('utf-8') |
-
diff --git a/django/core/management/commands/sqlreset.py b/django/core/management/commands/sqlreset.py
index 13f40de..976b848 100644
a
|
b
|
class Command(AppCommand):
|
17 | 17 | output_transaction = True |
18 | 18 | |
19 | 19 | def handle_app(self, app, **options): |
20 | | return u'\n'.join(sql_reset(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8') |
| 20 | return u'\n'.join(sql_reset(app, self.style, connections[options.get('database')])).encode('utf-8') |
-
diff --git a/django/core/management/commands/sqlsequencereset.py b/django/core/management/commands/sqlsequencereset.py
index aaab38b..6460f00 100644
a
|
b
|
class Command(AppCommand):
|
16 | 16 | output_transaction = True |
17 | 17 | |
18 | 18 | def handle_app(self, app, **options): |
19 | | connection = connections[options.get('database', DEFAULT_DB_ALIAS)] |
| 19 | connection = connections[options.get('database')] |
20 | 20 | return u'\n'.join(connection.ops.sequence_reset_sql(self.style, models.get_models(app, include_auto_created=True))).encode('utf-8') |
-
diff --git a/django/core/management/commands/syncdb.py b/django/core/management/commands/syncdb.py
index 4383c34..a9d803a 100644
a
|
b
|
class Command(NoArgsCommand):
|
22 | 22 | |
23 | 23 | def handle_noargs(self, **options): |
24 | 24 | |
25 | | verbosity = int(options.get('verbosity', 1)) |
| 25 | verbosity = int(options.get('verbosity')) |
26 | 26 | interactive = options.get('interactive') |
27 | | show_traceback = options.get('traceback', False) |
| 27 | show_traceback = options.get('traceback') |
28 | 28 | |
29 | 29 | # Stealth option -- 'load_initial_data' is used by the testing setup |
30 | 30 | # process to disable initial fixture loading. |
… |
… |
class Command(NoArgsCommand):
|
51 | 51 | if not msg.startswith('No module named') or 'management' not in msg: |
52 | 52 | raise |
53 | 53 | |
54 | | db = options.get('database', DEFAULT_DB_ALIAS) |
| 54 | db = options.get('database') |
55 | 55 | connection = connections[db] |
56 | 56 | cursor = connection.cursor() |
57 | 57 | |
-
diff --git a/django/core/management/commands/test.py b/django/core/management/commands/test.py
index 1b3f2be..2a6dbfc 100644
a
|
b
|
class Command(BaseCommand):
|
46 | 46 | from django.test.utils import get_runner |
47 | 47 | |
48 | 48 | TestRunner = get_runner(settings, options.get('testrunner')) |
49 | | options['verbosity'] = int(options.get('verbosity', 1)) |
50 | | options.setdefault('interactive', True) |
51 | | options.setdefault('failfast', False) |
| 49 | options['verbosity'] = int(options.get('verbosity')) |
52 | 50 | |
53 | 51 | test_runner = TestRunner(**options) |
54 | 52 | failures = test_runner.run_tests(test_labels) |
-
diff --git a/django/core/management/commands/testserver.py b/django/core/management/commands/testserver.py
index 3f62e57..2e0d8e4 100644
a
|
b
|
class Command(BaseCommand):
|
21 | 21 | from django.core.management import call_command |
22 | 22 | from django.db import connection |
23 | 23 | |
24 | | verbosity = int(options.get('verbosity', 1)) |
25 | | interactive = options.get('interactive', True) |
| 24 | verbosity = int(options.get('verbosity')) |
| 25 | interactive = options.get('interactive') |
26 | 26 | addrport = options.get('addrport') |
27 | 27 | |
28 | 28 | # Create a test database. |