Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extend unknown color error message #147

Merged
merged 2 commits into from
Aug 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/wireviz/wv_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,18 @@
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)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

except KeyError:
print("Unknown color specified")
print(f'Unknown color specified: {input}')
Copy link
Collaborator

@kvid kvid Aug 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my updated comments about white-space in #147 (comment), and about byte indicator and quotes in #147 (comment)

output = [color_default]
return output

Expand Down