1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 10:42:34 +01:00

update -K output to include quotes around keys

This commit is contained in:
Mike Fährmann 2023-03-21 22:28:04 +01:00
parent fe41a2b159
commit 2ab66ad899
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 6 additions and 6 deletions

View File

@ -633,7 +633,7 @@ class KeywordJob(Job):
def print_kwdict(self, kwdict, prefix="", markers=None): def print_kwdict(self, kwdict, prefix="", markers=None):
"""Print key-value pairs in 'kwdict' with formatting""" """Print key-value pairs in 'kwdict' with formatting"""
write = sys.stdout.write write = sys.stdout.write
suffix = "]" if prefix else "" suffix = "']" if prefix else ""
markerid = id(kwdict) markerid = id(kwdict)
if markers is None: if markers is None:
@ -650,13 +650,13 @@ class KeywordJob(Job):
key = prefix + key + suffix key = prefix + key + suffix
if isinstance(value, dict): if isinstance(value, dict):
self.print_kwdict(value, key + "[", markers) self.print_kwdict(value, key + "['", markers)
elif isinstance(value, list): elif isinstance(value, list):
if not value: if not value:
pass pass
elif isinstance(value[0], dict): elif isinstance(value[0], dict):
self.print_kwdict(value[0], key + "[N][", markers) self.print_kwdict(value[0], key + "[N]['", markers)
else: else:
fmt = (" {:>%s} {}\n" % len(str(len(value)))).format fmt = (" {:>%s} {}\n" % len(str(len(value)))).format
write(key + "[N]\n") write(key + "[N]\n")

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2021 Mike Fährmann # Copyright 2021-2023 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as # it under the terms of the GNU General Public License version 2 as
@ -91,9 +91,9 @@ tags[N]
0 foo 0 foo
1 bar 1 bar
2 テスト 2 テスト
user[id] user['id']
123 123
user[name] user['name']
test test
""") """)