mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
parent
e412317194
commit
5f0c37ccfc
@ -41,15 +41,20 @@ ERROR_STR = 'General Errors'
|
||||
|
||||
def color(the_color, *args, reset=None):
|
||||
"""Color helper."""
|
||||
from colorlog.escape_codes import escape_codes, parse_colors
|
||||
try:
|
||||
if not args:
|
||||
assert reset is None, "You cannot reset if nothing being printed"
|
||||
return parse_colors(the_color)
|
||||
return parse_colors(the_color) + ' '.join(args) + \
|
||||
escape_codes[reset or 'reset']
|
||||
except KeyError as k:
|
||||
raise ValueError("Invalid color {} in {}".format(str(k), the_color))
|
||||
from colorlog.escape_codes import escape_codes, parse_colors
|
||||
try:
|
||||
if not args:
|
||||
assert reset is None, "Cannot reset if nothing being printed"
|
||||
return parse_colors(the_color)
|
||||
return parse_colors(the_color) + ' '.join(args) + \
|
||||
escape_codes[reset or 'reset']
|
||||
except KeyError as k:
|
||||
raise ValueError(
|
||||
"Invalid color {} in {}".format(str(k), the_color))
|
||||
except ImportError:
|
||||
# We should fallback to black-and-white if colorlog is not installed
|
||||
return ' '.join(args)
|
||||
|
||||
|
||||
def run(script_args: List) -> int:
|
||||
|
Loading…
x
Reference in New Issue
Block a user