1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-11-01 21:02:38 +00:00

Add formatting switches for different use cases

This commit is contained in:
Dylan Dizon 2018-11-06 15:22:02 -05:00
parent a93cd158fa
commit 41a4fb9055

View file

@ -1,8 +1,8 @@
def tostring(i, *, order=None): def tostring(i, *, order=None, newline=False):
o = '' o = ''
if i: if i:
for v in i: for v in i:
o += v + ' ' o += v + (' ' if newline is False else '\n')
o = o[:-1] o = o[:-1]
elif order: elif order:
o += order o += order
@ -20,11 +20,17 @@ def tostring_commas(i):
return '' return ''
def dict_tostring(i): def dict_tostring(i, f=True):
o = '' o = ''
if i:
for k, v in i.items(): if f:
o += '**' + k + ':** `' + tostring(v) + '`\n' 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 return o