diff --git a/lib/parser.py b/lib/parser.py index fe40992..d4a9f91 100644 --- a/lib/parser.py +++ b/lib/parser.py @@ -111,15 +111,14 @@ def parse_key(key): # Parse color string, e.: '(255, 255, 255)' def parse_color(color, as_hex=False): + if type(color) is tuple: + return rgb2hex(color) if as_hex else color # check if RGB - if color.startswith('(') and color.endswith(')'): + elif color.startswith('(') and color.endswith(')'): values = color[1:-1].split(',') # [1:-1] will remove the first & last parentheses '(' ')' if len(values) == 3: rgb = (int(values[0]), int(values[1]), int(values[2])) - if as_hex: - return rgb2hex(rgb) - else: - return rgb + return rgb2hex(rgb) if as_hex else rgb else: return None # check if HEX