From fe6b87806433f04f0390cfcb80b0656a6a15f2fa Mon Sep 17 00:00:00 2001 From: kate Date: Sun, 19 May 2019 23:10:01 +0200 Subject: [PATCH] Fix info formatting in some cases (#8) --- stdplugins/info.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/stdplugins/info.py b/stdplugins/info.py index a22fc5a..9129ce2 100644 --- a/stdplugins/info.py +++ b/stdplugins/info.py @@ -37,7 +37,7 @@ def yaml_format(obj, indent=0): has_multiple_items = len(items) > 2 if has_multiple_items: result.append('\n') - indent += 2 + indent += 2 for k, v in items: if k == '_' or v is None: continue @@ -45,11 +45,14 @@ def yaml_format(obj, indent=0): if not formatted.strip(): continue result.append(' ' * (indent if has_multiple_items else 1)) - result.append(f'{k}: {formatted}') + result.append(f'{k}:') + if not formatted[0].isspace(): + result.append(' ') + result.append(f'{formatted}') result.append('\n') result.pop() - indent -= 2 - result.append(' ' * indent) + if has_multiple_items: + indent -= 2 elif isinstance(obj, str): # truncate long strings and display elipsis result = repr(obj[:STR_LEN_MAX]) @@ -75,7 +78,6 @@ def yaml_format(obj, indent=0): result.append('\n') result.pop() indent -= 2 - result.append(' ' * indent) else: return repr(obj)