Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
awarecan committed Mar 7, 2019
1 parent 1434fbb commit 17d79e1
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions homeassistant/scripts/check_config.py
Expand Up @@ -41,20 +41,15 @@

def color(the_color, *args, reset=None):
"""Color helper."""
from colorlog.escape_codes import escape_codes, parse_colors
try:
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)
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))


def run(script_args: List) -> int:
Expand Down

0 comments on commit 17d79e1

Please sign in to comment.