Skip to content

Commit

Permalink
make sure only the input and not the padded colors are given in the e…
Browse files Browse the repository at this point in the history
…rror message
  • Loading branch information
SnowMB committed Aug 5, 2020
1 parent ade9817 commit 15f183a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/wireviz/wv_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,19 @@
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]
# hacky style fix: give single color wires a triple-up so that wires are the same size
elif pad and len(input) == 2:
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

Expand Down

0 comments on commit 15f183a

Please sign in to comment.