Code

Ticket #13760: remove-duplicate-defaults.diff

File remove-duplicate-defaults.diff, 12.2 KB (added by adamv, 3 years ago)

Rebased against trunk.

Line 
1diff --git a/django/core/management/commands/createcachetable.py b/django/core/management/commands/createcachetable.py
2index 90172b6..a6628a0 100644
3--- a/django/core/management/commands/createcachetable.py
4+++ b/django/core/management/commands/createcachetable.py
5@@ -18,7 +18,7 @@ class Command(LabelCommand):
6     requires_model_validation = False
7 
8     def handle_label(self, tablename, **options):
9-        alias = options.get('database', DEFAULT_DB_ALIAS)
10+        alias = options.get('database')
11         connection = connections[alias]
12         fields = (
13             # "key" is a reserved word in MySQL, so use "cache_key" instead.
14diff --git a/django/core/management/commands/dbshell.py b/django/core/management/commands/dbshell.py
15index a6b5427..7465920 100644
16--- a/django/core/management/commands/dbshell.py
17+++ b/django/core/management/commands/dbshell.py
18@@ -16,7 +16,7 @@ class Command(BaseCommand):
19     requires_model_validation = False
20 
21     def handle(self, **options):
22-        connection = connections[options.get('database', DEFAULT_DB_ALIAS)]
23+        connection = connections[options.get('database')]
24         try:
25             connection.client.runshell()
26         except OSError:
27diff --git a/django/core/management/commands/dumpdata.py b/django/core/management/commands/dumpdata.py
28index 706bf60..162135a 100644
29--- a/django/core/management/commands/dumpdata.py
30+++ b/django/core/management/commands/dumpdata.py
31@@ -30,14 +30,14 @@ class Command(BaseCommand):
32     def handle(self, *app_labels, **options):
33         from django.db.models import get_app, get_apps, get_models, get_model
34 
35-        format = options.get('format','json')
36-        indent = options.get('indent',None)
37-        using = options.get('database', DEFAULT_DB_ALIAS)
38+        format = options.get('format')
39+        indent = options.get('indent')
40+        using = options.get('database')
41         connection = connections[using]
42-        excludes = options.get('exclude',[])
43-        show_traceback = options.get('traceback', False)
44-        use_natural_keys = options.get('use_natural_keys', False)
45-        use_base_manager = options.get('use_base_manager', False)
46+        excludes = options.get('exclude')
47+        show_traceback = options.get('traceback')
48+        use_natural_keys = options.get('use_natural_keys')
49+        use_base_manager = options.get('use_base_manager')
50 
51         excluded_apps = set()
52         excluded_models = set()
53diff --git a/django/core/management/commands/flush.py b/django/core/management/commands/flush.py
54index bcadb96..4eb329a 100644
55--- a/django/core/management/commands/flush.py
56+++ b/django/core/management/commands/flush.py
57@@ -20,9 +20,9 @@ class Command(NoArgsCommand):
58     help = "Executes ``sqlflush`` on the current database."
59 
60     def handle_noargs(self, **options):
61-        db = options.get('database', DEFAULT_DB_ALIAS)
62+        db = options.get('database')
63         connection = connections[db]
64-        verbosity = int(options.get('verbosity', 1))
65+        verbosity = int(options.get('verbosity'))
66         interactive = options.get('interactive')
67 
68         self.style = no_style()
69diff --git a/django/core/management/commands/inspectdb.py b/django/core/management/commands/inspectdb.py
70index e45f22c..27c4f0f 100644
71--- a/django/core/management/commands/inspectdb.py
72+++ b/django/core/management/commands/inspectdb.py
73@@ -25,7 +25,7 @@ class Command(NoArgsCommand):
74             raise CommandError("Database inspection isn't supported for the currently selected database backend.")
75 
76     def handle_inspection(self, options):
77-        connection = connections[options.get('database', DEFAULT_DB_ALIAS)]
78+        connection = connections[options.get('database')]
79 
80         table2model = lambda table_name: table_name.title().replace('_', '').replace(' ', '').replace('-', '')
81 
82diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py
83index 34f3543..2ca8db2 100644
84--- a/django/core/management/commands/loaddata.py
85+++ b/django/core/management/commands/loaddata.py
86@@ -29,13 +29,13 @@ class Command(BaseCommand):
87     )
88 
89     def handle(self, *fixture_labels, **options):
90-        using = options.get('database', DEFAULT_DB_ALIAS)
91+        using = options.get('database')
92 
93         connection = connections[using]
94         self.style = no_style()
95 
96-        verbosity = int(options.get('verbosity', 1))
97-        show_traceback = options.get('traceback', False)
98+        verbosity = int(options.get('verbosity'))
99+        show_traceback = options.get('traceback')
100 
101         # commit is a stealth option - it isn't really useful as
102         # a command line option, but it can be useful when invoking
103diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py
104index b63b57a..7324ff3 100644
105--- a/django/core/management/commands/runserver.py
106+++ b/django/core/management/commands/runserver.py
107@@ -128,4 +128,4 @@ class Command(BaseRunserverCommand):
108         Serves admin media like old-school (deprecation pending).
109         """
110         handler = super(Command, self).get_handler(*args, **options)
111-        return AdminMediaHandler(handler, options.get('admin_media_path', ''))
112+        return AdminMediaHandler(handler, options.get('admin_media_path'))
113diff --git a/django/core/management/commands/sql.py b/django/core/management/commands/sql.py
114index 582bc8e..59b2e77 100644
115--- a/django/core/management/commands/sql.py
116+++ b/django/core/management/commands/sql.py
117@@ -16,4 +16,4 @@ class Command(AppCommand):
118     output_transaction = True
119 
120     def handle_app(self, app, **options):
121-        return u'\n'.join(sql_create(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
122+        return u'\n'.join(sql_create(app, self.style, connections[options.get('database')])).encode('utf-8')
123diff --git a/django/core/management/commands/sqlall.py b/django/core/management/commands/sqlall.py
124index 8f3a38e..ab702bf 100644
125--- a/django/core/management/commands/sqlall.py
126+++ b/django/core/management/commands/sqlall.py
127@@ -16,4 +16,4 @@ class Command(AppCommand):
128     output_transaction = True
129 
130     def handle_app(self, app, **options):
131-        return u'\n'.join(sql_all(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
132+        return u'\n'.join(sql_all(app, self.style, connections[options.get('database')])).encode('utf-8')
133diff --git a/django/core/management/commands/sqlclear.py b/django/core/management/commands/sqlclear.py
134index c7e3a5e..b8f4913 100644
135--- a/django/core/management/commands/sqlclear.py
136+++ b/django/core/management/commands/sqlclear.py
137@@ -16,4 +16,4 @@ class Command(AppCommand):
138     output_transaction = True
139 
140     def handle_app(self, app, **options):
141-        return u'\n'.join(sql_delete(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
142+        return u'\n'.join(sql_delete(app, self.style, connections[options.get('database')])).encode('utf-8')
143diff --git a/django/core/management/commands/sqlcustom.py b/django/core/management/commands/sqlcustom.py
144index d206b04..6a98456 100644
145--- a/django/core/management/commands/sqlcustom.py
146+++ b/django/core/management/commands/sqlcustom.py
147@@ -16,4 +16,4 @@ class Command(AppCommand):
148     output_transaction = True
149 
150     def handle_app(self, app, **options):
151-        return u'\n'.join(sql_custom(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
152+        return u'\n'.join(sql_custom(app, self.style, connections[options.get('database')])).encode('utf-8')
153diff --git a/django/core/management/commands/sqlflush.py b/django/core/management/commands/sqlflush.py
154index 004f0a5..19054fb 100644
155--- a/django/core/management/commands/sqlflush.py
156+++ b/django/core/management/commands/sqlflush.py
157@@ -16,4 +16,4 @@ class Command(NoArgsCommand):
158     output_transaction = True
159 
160     def handle_noargs(self, **options):
161-        return u'\n'.join(sql_flush(self.style, connections[options.get('database', DEFAULT_DB_ALIAS)], only_django=True)).encode('utf-8')
162+        return u'\n'.join(sql_flush(self.style, connections[options.get('database')], only_django=True)).encode('utf-8')
163diff --git a/django/core/management/commands/sqlindexes.py b/django/core/management/commands/sqlindexes.py
164index c889f03..bf55b0d 100644
165--- a/django/core/management/commands/sqlindexes.py
166+++ b/django/core/management/commands/sqlindexes.py
167@@ -17,4 +17,4 @@ class Command(AppCommand):
168     output_transaction = True
169 
170     def handle_app(self, app, **options):
171-        return u'\n'.join(sql_indexes(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
172+        return u'\n'.join(sql_indexes(app, self.style, connections[options.get('database')])).encode('utf-8')
173diff --git a/django/core/management/commands/sqlreset.py b/django/core/management/commands/sqlreset.py
174index 13f40de..976b848 100644
175--- a/django/core/management/commands/sqlreset.py
176+++ b/django/core/management/commands/sqlreset.py
177@@ -17,4 +17,4 @@ class Command(AppCommand):
178     output_transaction = True
179 
180     def handle_app(self, app, **options):
181-        return u'\n'.join(sql_reset(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
182+        return u'\n'.join(sql_reset(app, self.style, connections[options.get('database')])).encode('utf-8')
183diff --git a/django/core/management/commands/sqlsequencereset.py b/django/core/management/commands/sqlsequencereset.py
184index aaab38b..6460f00 100644
185--- a/django/core/management/commands/sqlsequencereset.py
186+++ b/django/core/management/commands/sqlsequencereset.py
187@@ -16,5 +16,5 @@ class Command(AppCommand):
188     output_transaction = True
189 
190     def handle_app(self, app, **options):
191-        connection = connections[options.get('database', DEFAULT_DB_ALIAS)]
192+        connection = connections[options.get('database')]
193         return u'\n'.join(connection.ops.sequence_reset_sql(self.style, models.get_models(app, include_auto_created=True))).encode('utf-8')
194diff --git a/django/core/management/commands/syncdb.py b/django/core/management/commands/syncdb.py
195index 3c11a26..5602246 100644
196--- a/django/core/management/commands/syncdb.py
197+++ b/django/core/management/commands/syncdb.py
198@@ -22,9 +22,9 @@ class Command(NoArgsCommand):
199 
200     def handle_noargs(self, **options):
201 
202-        verbosity = int(options.get('verbosity', 1))
203+        verbosity = int(options.get('verbosity'))
204         interactive = options.get('interactive')
205-        show_traceback = options.get('traceback', False)
206+        show_traceback = options.get('traceback')
207 
208         self.style = no_style()
209 
210@@ -47,7 +47,7 @@ class Command(NoArgsCommand):
211                 if not msg.startswith('No module named') or 'management' not in msg:
212                     raise
213 
214-        db = options.get('database', DEFAULT_DB_ALIAS)
215+        db = options.get('database')
216         connection = connections[db]
217         cursor = connection.cursor()
218 
219diff --git a/django/core/management/commands/test.py b/django/core/management/commands/test.py
220index 1431f00..c4924ba 100644
221--- a/django/core/management/commands/test.py
222+++ b/django/core/management/commands/test.py
223@@ -18,9 +18,9 @@ class Command(BaseCommand):
224         from django.conf import settings
225         from django.test.utils import get_runner
226 
227-        verbosity = int(options.get('verbosity', 1))
228-        interactive = options.get('interactive', True)
229-        failfast = options.get('failfast', False)
230+        verbosity = int(options.get('verbosity'))
231+        interactive = options.get('interactive')
232+        failfast = options.get('failfast')
233         TestRunner = get_runner(settings)
234 
235         if hasattr(TestRunner, 'func_name'):
236diff --git a/django/core/management/commands/testserver.py b/django/core/management/commands/testserver.py
237index 3f62e57..2e0d8e4 100644
238--- a/django/core/management/commands/testserver.py
239+++ b/django/core/management/commands/testserver.py
240@@ -21,8 +21,8 @@ class Command(BaseCommand):
241         from django.core.management import call_command
242         from django.db import connection
243 
244-        verbosity = int(options.get('verbosity', 1))
245-        interactive = options.get('interactive', True)
246+        verbosity = int(options.get('verbosity'))
247+        interactive = options.get('interactive')
248         addrport = options.get('addrport')
249 
250         # Create a test database.