Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #13760 -- Cleaned up unnecessary default option handling in a b…

…unch of management commands. Thanks to Paul McMillan for the report and to adamv and Claude Paroz for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17028 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 59c051d1707ec1c32256193221b6ee2e3e533be5 1 parent adf51b0
Julien Phalip authored October 23, 2011
2  django/core/management/commands/createcachetable.py
@@ -18,7 +18,7 @@ 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.
2  django/core/management/commands/dbshell.py
@@ -16,7 +16,7 @@ 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:
14  django/core/management/commands/dumpdata.py
@@ -30,13 +30,13 @@ 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()
4  django/core/management/commands/flush.py
@@ -23,9 +23,9 @@ 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()
2  django/core/management/commands/inspectdb.py
@@ -25,7 +25,7 @@ def handle_noargs(self, **options):
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
 
6  django/core/management/commands/loaddata.py
@@ -34,13 +34,13 @@ 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
2  django/core/management/commands/runserver.py
@@ -139,4 +139,4 @@ def get_handler(self, *args, **options):
139 139
         Serves admin media like old-school (deprecation pending).
140 140
         """
141 141
         handler = super(Command, self).get_handler(*args, **options)
142  
-        return AdminMediaHandler(handler, options.get('admin_media_path', ''))
  142
+        return AdminMediaHandler(handler, options.get('admin_media_path'))
2  django/core/management/commands/sql.py
@@ -16,4 +16,4 @@ 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')
2  django/core/management/commands/sqlall.py
@@ -16,4 +16,4 @@ 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')
2  django/core/management/commands/sqlclear.py
@@ -16,4 +16,4 @@ 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')
2  django/core/management/commands/sqlcustom.py
@@ -16,4 +16,4 @@ 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')
2  django/core/management/commands/sqlflush.py
@@ -16,4 +16,4 @@ 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')
2  django/core/management/commands/sqlindexes.py
@@ -17,4 +17,4 @@ 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')
2  django/core/management/commands/sqlreset.py
@@ -17,4 +17,4 @@ 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')
2  django/core/management/commands/sqlsequencereset.py
@@ -16,5 +16,5 @@ 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')
6  django/core/management/commands/syncdb.py
@@ -22,9 +22,9 @@ 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.
@@ -51,7 +51,7 @@ def handle_noargs(self, **options):
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
 
4  django/core/management/commands/test.py
@@ -46,9 +46,7 @@ def handle(self, *test_labels, **options):
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)
4  django/core/management/commands/testserver.py
@@ -21,8 +21,8 @@ def handle(self, *fixture_labels, **options):
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.

0 notes on commit 59c051d

Please sign in to comment.
Something went wrong with that request. Please try again.