hide empty objects

kate
udf 2018-11-03 04:53:32 +02:00
parent 774c0bebdb
commit 192e1d890a
Signed by: kate
GPG Key ID: E40724BAD73AF77B
1 changed files with 4 additions and 1 deletions

View File

@ -44,8 +44,11 @@ def yaml_format(obj, indent=0):
for k, v in items:
if k == '_' or v is None:
continue
formatted = yaml_format(v, indent)
if not formatted.strip():
continue
result.append(' ' * (indent if has_multiple_items else 1))
result.append(f'{k}: {yaml_format(v, indent)}')
result.append(f'{k}: {formatted}')
result.append('\n')
result.pop()
indent -= 2