Allow strings to be passed to print_colored()
This commit is contained in:
parent
f55f0ba016
commit
5925aca3c2
1 changed files with 6 additions and 0 deletions
|
|
@ -807,6 +807,12 @@ def print_colored(strings, colors, **kwargs):
|
||||||
'flush': kwargs.get('flush', False),
|
'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
|
# Build new string with color escapes added
|
||||||
for string, color in itertools.zip_longest(strings, colors):
|
for string, color in itertools.zip_longest(strings, colors):
|
||||||
color_code = COLORS.get(color, clear_code)
|
color_code = COLORS.get(color, clear_code)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue