From 41a4fb90558119ec0294c8a4176fe1bd9e60160e Mon Sep 17 00:00:00 2001 From: Dylan Dizon Date: Tue, 6 Nov 2018 15:22:02 -0500 Subject: [PATCH] Add formatting switches for different use cases --- src/utils/formatter.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/utils/formatter.py b/src/utils/formatter.py index 87f3f74..d6fe811 100644 --- a/src/utils/formatter.py +++ b/src/utils/formatter.py @@ -1,8 +1,8 @@ -def tostring(i, *, order=None): +def tostring(i, *, order=None, newline=False): o = '' if i: for v in i: - o += v + ' ' + o += v + (' ' if newline is False else '\n') o = o[:-1] elif order: o += order @@ -20,11 +20,17 @@ def tostring_commas(i): return '' -def dict_tostring(i): +def dict_tostring(i, f=True): o = '' - if i: - for k, v in i.items(): - o += '**' + k + ':** `' + tostring(v) + '`\n' + + if f: + if i: + for k, v in i.items(): + o += '**' + k + ':** `' + tostring(v) + '`\n' + else: + if i: + for k, v in i.items(): + o += k + ': ```' + tostring(v, newline=True) + '```\n' return o