Cleaned up wv_colors.py

*Reformatted with autopep8
*renamed input->inp to avoid shadowing input() function
This commit is contained in:
Gabe R 2020-06-28 23:52:52 -05:00
parent 854f06dd79
commit 9cb3608b27
No known key found for this signature in database
GPG Key ID: F96D83D8D7ED67D0

View File

@ -1,7 +1,10 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
COLOR_CODES = { COLOR_CODES = {
'DIN': ['WH','BN','GN','YE','GY','PK','BU','RD','BK','VT'], # ,'GYPK','RDBU','WHGN','BNGN','WHYE','YEBN','WHGY','GYBN','WHPK','PKBN'], # ,'GYPK','RDBU','WHGN','BNGN','WHYE','YEBN','WHGY','GYBN','WHPK','PKBN'],
'DIN': ['WH', 'BN', 'GN', 'YE', 'GY', 'PK', 'BU', 'RD', 'BK', 'VT'],
'IEC': ['BN', 'RD', 'OG', 'YE', 'GN', 'BU', 'VT', 'GY', 'WH', 'BK'], 'IEC': ['BN', 'RD', 'OG', 'YE', 'GN', 'BU', 'VT', 'GY', 'WH', 'BK'],
'BW': ['BK','WH'] 'BW': ['BK', 'WH'],
} }
color_hex = { color_hex = {
@ -49,26 +52,27 @@ color_ger = {
'BN': 'br', 'BN': 'br',
} }
def translate_color(input, color_mode):
if input == '': def translate_color(inp, color_mode):
if inp == '':
output = '' output = ''
else: else:
if color_mode == 'full': if color_mode == 'full':
output = color_full[input].lower() output = color_full[inp].lower()
elif color_mode == 'FULL': elif color_mode == 'FULL':
output = color_full[input].upper() output = color_full[inp].upper()
elif color_mode == 'hex': elif color_mode == 'hex':
output = color_hex[input].lower() output = color_hex[inp].lower()
elif color_mode == 'HEX': elif color_mode == 'HEX':
output = color_hex[input].upper() output = color_hex[inp].upper()
elif color_mode == 'ger': elif color_mode == 'ger':
output = color_ger[input].lower() output = color_ger[inp].lower()
elif color_mode == 'GER': elif color_mode == 'GER':
output = color_ger[input].upper() output = color_ger[inp].upper()
elif color_mode == 'short': elif color_mode == 'short':
output = input.lower() output = inp.lower()
elif color_mode == 'SHORT': elif color_mode == 'SHORT':
output = input.upper() output = inp.upper()
else: else:
raise Exception('Unknown color mode') raise Exception('Unknown color mode')
return output return output