attempt to improve '-K' output for lists

- use [N] instead if [] to indicate a Number needs to be placed there
- enumerate list items
This commit is contained in:
Mike Fährmann
2022-10-28 12:04:58 +02:00
parent e140b85342
commit f037429fa4
2 changed files with 12 additions and 9 deletions

View File

@@ -605,12 +605,15 @@ class KeywordJob(Job):
self.print_kwdict(value, key + "[", markers)
elif isinstance(value, list):
if value and isinstance(value[0], dict):
self.print_kwdict(value[0], key + "[][", markers)
if not value:
pass
elif isinstance(value[0], dict):
self.print_kwdict(value[0], key + "[N][", markers)
else:
write(key + "[]\n")
for val in value:
write(" - " + str(val) + "\n")
fmt = (" {:>%s} {}\n" % len(str(len(value)))).format
write(key + "[N]\n")
for idx, val in enumerate(value, 0):
write(fmt(idx, val))
else:
# string or number

View File

@@ -87,10 +87,10 @@ num
1
subcategory
test_subcategory
tags[]
- foo
- bar
- テスト
tags[N]
0 foo
1 bar
2 テスト
user[id]
123
user[name]