Allow strings to be passed to print_colored()

This commit is contained in:
2Shirt 2019-09-18 20:02:39 -07:00
parent f55f0ba016
commit 5925aca3c2
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -807,6 +807,12 @@ def print_colored(strings, colors, **kwargs):
'flush': kwargs.get('flush', False),
}
# Convert to tuples if necessary
if isinstance(strings, str):
strings = (strings,)
if isinstance(colors, str):
colors = (colors,)
# Build new string with color escapes added
for string, color in itertools.zip_longest(strings, colors):
color_code = COLORS.get(color, clear_code)