commit
3562c0e18b
@ -129,7 +129,7 @@ class Harness:
|
|||||||
html = html + '</tr>' # attribute row
|
html = html + '</tr>' # attribute row
|
||||||
html = html + '</table></td></tr>' # name+attributes table
|
html = html + '</table></td></tr>' # name+attributes table
|
||||||
|
|
||||||
html = html + '<tr><td> </td></tr>' # spacer between attributes and wires
|
html = html + '<tr><td></td></tr>' # spacer between attributes and wires
|
||||||
|
|
||||||
html = html + '<tr><td><table border="0" cellspacing="0" cellborder="0">' # conductor table
|
html = html + '<tr><td><table border="0" cellspacing="0" cellborder="0">' # conductor table
|
||||||
|
|
||||||
@ -142,19 +142,12 @@ class Harness:
|
|||||||
for bla in p:
|
for bla in p:
|
||||||
html = html + '<td>{}</td>'.format(bla)
|
html = html + '<td>{}</td>'.format(bla)
|
||||||
html = html + '</tr>'
|
html = html + '</tr>'
|
||||||
colors = wv_colors.translate_color(x,'hex').split(':')
|
bgcolors = ('#000000:' + wv_colors.translate_color(x, 'hex') +':#000000').split(':')
|
||||||
rowheight = 6 #/ len(colors)
|
html = html + '<tr><td colspan="{colspan}" border="0" cellspacing="0" cellpadding="0" port="{port}" height="{height}"><table cellspacing="0" cellborder="0" border = "0">'.format(colspan=len(p), port ='w{}'.format(i), height = '{}'.format(2*len(bgcolors)))
|
||||||
collen = len(p) / len(colors)
|
for j, bgcolor in enumerate(bgcolors):
|
||||||
html = html + '<tr cellpadding="0" cellspacing="0" border="0"><td border="2" sides="tb" colspan="{colspan}" cellspacing="0" cellpadding="0" port="{port}"><table cellspacing="0" cellpadding="0" border="0"><tr>'.format(colspan=len(p), port='w{}'.format(i))
|
html = html + '<tr><td colspan="{colspan}" cellpadding="0" height="2" bgcolor="{bgcolor}" border="0"></td></tr>'.format(colspan=len(p), bgcolor=bgcolor if bgcolor != '' else '#ffffff')
|
||||||
for j, bgcolor in enumerate(colors,1):
|
html = html + '</table></td></tr>'
|
||||||
# todo border 2
|
|
||||||
# port="{port}"
|
|
||||||
# html = html + '<td colspan="{colspan}" cellpadding="0" height="{rowheight}" bgcolor="{bgcolor}" border="1" sides="tb" {port}></td>'.format(
|
|
||||||
# colspan=collen, bgcolor=bgcolor if bgcolor != '' else wv_colors.default_color,
|
|
||||||
# port='port="w{}"'.format(i) if j == len(colors) else '', rowheight=rowheight)
|
|
||||||
html = html + '<td colspan="{colspan}" cellspacing="0" cellpadding="0" height="{rowheight}" bgcolor="{bgcolor}" ></td>'.format(
|
|
||||||
colspan=collen, bgcolor=bgcolor if bgcolor != '' else wv_colors.default_color, rowheight=rowheight)
|
|
||||||
html = html + '</tr></table></td></tr>'
|
|
||||||
if c.shield:
|
if c.shield:
|
||||||
p = ['<!-- s_in -->', 'Shield', '<!-- s_out -->']
|
p = ['<!-- s_in -->', 'Shield', '<!-- s_out -->']
|
||||||
html = html + '<tr><td></td></tr>' # spacer
|
html = html + '<tr><td></td></tr>' # spacer
|
||||||
|
|||||||
@ -49,8 +49,8 @@ _color_hex = {
|
|||||||
'PE': '#54aa85:#f7f854:#54aa85',
|
'PE': '#54aa85:#f7f854:#54aa85',
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: Add a helper method for this, that can deal with banded wires
|
|
||||||
color_full = {
|
_color_full = {
|
||||||
'BK': 'black',
|
'BK': 'black',
|
||||||
'WH': 'white',
|
'WH': 'white',
|
||||||
'GY': 'grey',
|
'GY': 'grey',
|
||||||
@ -65,11 +65,11 @@ color_full = {
|
|||||||
'BN': 'brown',
|
'BN': 'brown',
|
||||||
'SL': 'slate',
|
'SL': 'slate',
|
||||||
'CU': 'bare copper',
|
'CU': 'bare copper',
|
||||||
'TI': 'tinned copper',
|
'TI': 'tinned copper', # Could be changed to SN, as that's the elemental symbol
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO Help wanted! Need help translating colors/banded colors to german shortcodes
|
# TODO Help wanted: can someone check the german translation?
|
||||||
color_ger = {
|
_color_ger = {
|
||||||
'BK': 'sw',
|
'BK': 'sw',
|
||||||
'WH': 'ws',
|
'WH': 'ws',
|
||||||
'GY': 'gr',
|
'GY': 'gr',
|
||||||
@ -82,43 +82,50 @@ color_ger = {
|
|||||||
'BU': 'bl',
|
'BU': 'bl',
|
||||||
'VT': 'vi',
|
'VT': 'vi',
|
||||||
'BN': 'br',
|
'BN': 'br',
|
||||||
|
# To the best of my ability, likely incorrect:
|
||||||
|
|
||||||
|
# Slate --> Schieferfarbe --> SI ??
|
||||||
|
'SL': 'si',
|
||||||
|
# Copper
|
||||||
|
'CU': 'ku',
|
||||||
|
# Tinned
|
||||||
|
'TI': 'si'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_color_hex(input):
|
def get_color_hex(input):
|
||||||
if len(input) == 4: # give wires with EXACTLY 2 colors that striped/banded look
|
if len(input) == 4: # give wires with EXACTLY 2 colors that striped/banded look
|
||||||
input = input + input[:2]
|
input = input + input[:2]
|
||||||
output = ''
|
try:
|
||||||
for i in range(0, len(input), 2): # Split into 2 letter chunks
|
output = ":".join([_color_hex[input[i:i + 2]] for i in range(0, len(input), 2)])
|
||||||
if input[i:i + 2] in color_hex:
|
except KeyError:
|
||||||
output += color_hex[input[i:i + 2]]
|
raise Exception('Unknown Color Name')
|
||||||
if i + 2 != len(input):
|
|
||||||
output += ':'
|
|
||||||
if output == '':
|
if output == '':
|
||||||
output = _default_color
|
output = default_color
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
def translate_color(input, color_mode):
|
def translate_color(input, color_mode):
|
||||||
if input == '':
|
if input == '':
|
||||||
output = ''
|
return ''
|
||||||
else:
|
upper = color_mode.isupper()
|
||||||
|
if not (color_mode.isupper() or color_mode.islower()):
|
||||||
|
raise Exception('Unknown color mode capitalization')
|
||||||
|
|
||||||
|
color_mode = color_mode.lower()
|
||||||
if color_mode == 'full':
|
if color_mode == 'full':
|
||||||
output = color_full[input].lower()
|
output = "/".join([_color_full[input[i:i+2]] for i in range(0,len(input),2)])
|
||||||
elif color_mode == 'FULL':
|
|
||||||
output = color_full[input].upper()
|
|
||||||
elif color_mode == 'hex':
|
elif color_mode == 'hex':
|
||||||
output = get_color_hex(input).lower()
|
output = get_color_hex(input)
|
||||||
elif color_mode == 'HEX':
|
|
||||||
output = get_color_hex(input).upper()
|
|
||||||
elif color_mode == 'ger':
|
elif color_mode == 'ger':
|
||||||
output = color_ger[input].lower()
|
output = "".join([_color_ger[input[i:i+2]] for i in range(o,len(input),2)])
|
||||||
elif color_mode == 'GER':
|
|
||||||
output = color_ger[input].upper()
|
|
||||||
elif color_mode == 'short':
|
elif color_mode == 'short':
|
||||||
output = input.lower()
|
output = input
|
||||||
elif color_mode == 'SHORT':
|
|
||||||
output = input.upper()
|
|
||||||
else:
|
else:
|
||||||
raise Exception('Unknown color mode')
|
raise Exception('Unknown color mode')
|
||||||
return output
|
if upper:
|
||||||
|
return output.upper()
|
||||||
|
else:
|
||||||
|
return output.lower()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user