diff options
| author | Tim Graham <timograham@gmail.com> | 2016-03-28 18:33:29 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-04-08 09:51:06 -0400 |
| commit | df8d8d4292684d6ffa7474f1e201aed486f02b53 (patch) | |
| tree | c661bf9b33de5288afe4f63347a2a9c768ef98eb /django/core/management/commands/dumpdata.py | |
| parent | 2956e2f5e3f63d279f5dae2a995265364d3e6db1 (diff) | |
Fixed E128 flake8 warnings in django/.
Diffstat (limited to 'django/core/management/commands/dumpdata.py')
| -rw-r--r-- | django/core/management/commands/dumpdata.py | 89 |
1 files changed, 56 insertions, 33 deletions
diff --git a/django/core/management/commands/dumpdata.py b/django/core/management/commands/dumpdata.py index f8edcafabb..b8547d684f 100644 --- a/django/core/management/commands/dumpdata.py +++ b/django/core/management/commands/dumpdata.py @@ -12,37 +12,57 @@ class ProxyModelWarning(Warning): class Command(BaseCommand): - help = ("Output the contents of the database as a fixture of the given " - "format (using each model's default manager unless --all is " - "specified).") + help = ( + "Output the contents of the database as a fixture of the given format " + "(using each model's default manager unless --all is specified)." + ) def add_arguments(self, parser): - parser.add_argument('args', metavar='app_label[.ModelName]', nargs='*', - help='Restricts dumped data to the specified app_label or app_label.ModelName.') - parser.add_argument('--format', default='json', dest='format', - help='Specifies the output serialization format for fixtures.') - parser.add_argument('--indent', default=None, dest='indent', type=int, - help='Specifies the indent level to use when pretty-printing output.') - parser.add_argument('--database', action='store', dest='database', + parser.add_argument( + 'args', metavar='app_label[.ModelName]', nargs='*', + help='Restricts dumped data to the specified app_label or app_label.ModelName.', + ) + parser.add_argument( + '--format', default='json', dest='format', + help='Specifies the output serialization format for fixtures.', + ) + parser.add_argument( + '--indent', default=None, dest='indent', type=int, + help='Specifies the indent level to use when pretty-printing output.', + ) + parser.add_argument( + '--database', action='store', dest='database', default=DEFAULT_DB_ALIAS, help='Nominates a specific database to dump fixtures from. ' - 'Defaults to the "default" database.') - parser.add_argument('-e', '--exclude', dest='exclude', action='append', default=[], + 'Defaults to the "default" database.', + ) + parser.add_argument( + '-e', '--exclude', dest='exclude', action='append', default=[], help='An app_label or app_label.ModelName to exclude ' - '(use multiple --exclude to exclude multiple apps/models).') - parser.add_argument('--natural-foreign', action='store_true', dest='use_natural_foreign_keys', default=False, - help='Use natural foreign keys if they are available.') - parser.add_argument('--natural-primary', action='store_true', dest='use_natural_primary_keys', default=False, - help='Use natural primary keys if they are available.') - parser.add_argument('-a', '--all', action='store_true', dest='use_base_manager', default=False, + '(use multiple --exclude to exclude multiple apps/models).', + ) + parser.add_argument( + '--natural-foreign', action='store_true', dest='use_natural_foreign_keys', default=False, + help='Use natural foreign keys if they are available.', + ) + parser.add_argument( + '--natural-primary', action='store_true', dest='use_natural_primary_keys', default=False, + help='Use natural primary keys if they are available.', + ) + parser.add_argument( + '-a', '--all', action='store_true', dest='use_base_manager', default=False, help="Use Django's base manager to dump all models stored in the database, " - "including those that would otherwise be filtered or modified by a custom manager.") - parser.add_argument('--pks', dest='primary_keys', - help="Only dump objects with given primary keys. " - "Accepts a comma separated list of keys. " - "This option will only work when you specify one model.") - parser.add_argument('-o', '--output', default=None, dest='output', - help='Specifies file to which the output is written.') + "including those that would otherwise be filtered or modified by a custom manager.", + ) + parser.add_argument( + '--pks', dest='primary_keys', + help="Only dump objects with given primary keys. Accepts a comma-separated " + "list of keys. This option only works when you specify one model.", + ) + parser.add_argument( + '-o', '--output', default=None, dest='output', + help='Specifies file to which the output is written.' + ) def handle(self, *app_labels, **options): format = options['format'] @@ -80,9 +100,10 @@ class Command(BaseCommand): if len(app_labels) == 0: if primary_keys: raise CommandError("You can only use --pks option with one model") - app_list = OrderedDict((app_config, None) - for app_config in apps.get_app_configs() - if app_config.models_module is not None and app_config not in excluded_apps) + app_list = OrderedDict( + (app_config, None) for app_config in apps.get_app_configs() + if app_config.models_module is not None and app_config not in excluded_apps + ) else: if len(app_labels) > 1 and primary_keys: raise CommandError("You can only use --pks option with one model") @@ -171,11 +192,13 @@ class Command(BaseCommand): object_count = sum(get_objects(count_only=True)) stream = open(output, 'w') if output else None try: - serializers.serialize(format, get_objects(), indent=indent, - use_natural_foreign_keys=use_natural_foreign_keys, - use_natural_primary_keys=use_natural_primary_keys, - stream=stream or self.stdout, progress_output=progress_output, - object_count=object_count) + serializers.serialize( + format, get_objects(), indent=indent, + use_natural_foreign_keys=use_natural_foreign_keys, + use_natural_primary_keys=use_natural_primary_keys, + stream=stream or self.stdout, progress_output=progress_output, + object_count=object_count, + ) finally: if stream: stream.close() |
