From cd212b8d63f02d16f8dd190c76b409ddf6cc96e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Br=C3=BCckner?= Date: Wed, 5 Aug 2020 11:54:51 +0200 Subject: [PATCH] make sure only the input and not the padded colors are given in the error message --- src/wireviz/wv_colors.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/wireviz/wv_colors.py b/src/wireviz/wv_colors.py index cb24183..c6b7219 100644 --- a/src/wireviz/wv_colors.py +++ b/src/wireviz/wv_colors.py @@ -104,15 +104,18 @@ color_default = '#ffffff' def get_color_hex(input, pad=False): if input is None or input == '': return [color_default] + if len(input) == 4: # give wires with EXACTLY 2 colors that striped/banded look - input = input + input[:2] - # hacky style fix: give single color wires a triple-up so that wires are the same size - if pad and len(input) == 2: - input = input + input + input + padded = input + input[:2] + elif pad and len(input) == 2: # hacky style fix: give single color wires a triple-up so that wires are the same size + padded = input + input + input + else: + padded = input + try: - output = [_color_hex[input[i:i + 2]] for i in range(0, len(input), 2)] + output = [_color_hex[padded[i:i + 2]] for i in range(0, len(input), 2)] except KeyError: - print(f"Unknown color specified: {input}") + print(f'Unknown color specified: {input}') output = [color_default] return output