Simplify code and rename variables
This commit is contained in:
parent
35ee54635b
commit
43d7665b8e
@ -177,19 +177,18 @@ class Harness:
|
|||||||
wirehtml = f'{wirehtml}<tr><td> </td></tr>'
|
wirehtml = f'{wirehtml}<tr><td> </td></tr>'
|
||||||
|
|
||||||
for i, connection_color in enumerate(cable.colors, 1):
|
for i, connection_color in enumerate(cable.colors, 1):
|
||||||
p = []
|
wirerow = [f'<!-- {i}_in -->',
|
||||||
p.append(f'<!-- {i}_in -->')
|
wv_colors.translate_color(connection_color, self.color_mode),
|
||||||
p.append(wv_colors.translate_color(connection_color, self.color_mode))
|
f'<!-- {i}_out -->']
|
||||||
p.append(f'<!-- {i}_out -->')
|
|
||||||
wirehtml = f'{wirehtml}<tr>'
|
wirehtml = f'{wirehtml}<tr>'
|
||||||
for bla in p:
|
for cell in wirerow:
|
||||||
wirehtml = f'{wirehtml}<td>{bla}</td>'
|
wirehtml = f'{wirehtml}<td>{cell}</td>'
|
||||||
wirehtml = f'{wirehtml}</tr>'
|
wirehtml = f'{wirehtml}</tr>'
|
||||||
|
|
||||||
bgcolors = ['#000000'] + get_color_hex(connection_color, pad=pad) + ['#000000']
|
bgcolors = ['#000000'] + get_color_hex(connection_color, pad=pad) + ['#000000']
|
||||||
wirehtml = f'{wirehtml}<tr><td colspan="{len(p)}" border="0" cellspacing="0" cellpadding="0" port="w{i}" height="{(2 * len(bgcolors))}"><table cellspacing="0" cellborder="0" border = "0">'
|
wirehtml = f'{wirehtml}<tr><td colspan="{len(wirerow)}" border="0" cellspacing="0" cellpadding="0" port="w{i}" height="{(2 * len(bgcolors))}"><table cellspacing="0" cellborder="0" border = "0">'
|
||||||
for j, bgcolor in enumerate(bgcolors[::-1]): # Reverse to match the curved wires when more than 2 colors
|
for j, bgcolor in enumerate(bgcolors[::-1]): # Reverse to match the curved wires when more than 2 colors
|
||||||
wirehtml = f'{wirehtml}<tr><td colspan="{len(p)}" cellpadding="0" height="2" bgcolor="{bgcolor if bgcolor != "" else wv_colors.default_color}" border="0"></td></tr>'
|
wirehtml = f'{wirehtml}<tr><td colspan="{len(wirerow)}" cellpadding="0" height="2" bgcolor="{bgcolor if bgcolor != "" else wv_colors.default_color}" border="0"></td></tr>'
|
||||||
wirehtml = wirehtml + '</table></td></tr>'
|
wirehtml = wirehtml + '</table></td></tr>'
|
||||||
if(cable.category == 'bundle'): # for bundles individual wires can have part information
|
if(cable.category == 'bundle'): # for bundles individual wires can have part information
|
||||||
# create a list of wire parameters
|
# create a list of wire parameters
|
||||||
@ -202,17 +201,17 @@ class Harness:
|
|||||||
wireidentification.append(manufacturer_info)
|
wireidentification.append(manufacturer_info)
|
||||||
# print parameters into a table row under the wire
|
# print parameters into a table row under the wire
|
||||||
if(len(wireidentification) > 0):
|
if(len(wireidentification) > 0):
|
||||||
wirehtml = f'{wirehtml}<tr><td colspan="{len(p)}"><table border="0" cellspacing="0" cellborder="0"><tr>'
|
wirehtml = f'{wirehtml}<tr><td colspan="{len(wirerow)}"><table border="0" cellspacing="0" cellborder="0"><tr>'
|
||||||
for attrib in wireidentification:
|
for attrib in wireidentification:
|
||||||
wirehtml = f'{wirehtml}<td>{attrib}</td>'
|
wirehtml = f'{wirehtml}<td>{attrib}</td>'
|
||||||
wirehtml = f'{wirehtml}</tr></table></td></tr>'
|
wirehtml = f'{wirehtml}</tr></table></td></tr>'
|
||||||
|
|
||||||
if cable.shield:
|
if cable.shield:
|
||||||
p = ['<!-- s_in -->', 'Shield', '<!-- s_out -->']
|
wirerow = ['<!-- s_in -->', 'Shield', '<!-- s_out -->']
|
||||||
wirehtml = f'{wirehtml}<tr><td> </td></tr>' # spacer
|
wirehtml = f'{wirehtml}<tr><td> </td></tr>' # spacer
|
||||||
wirehtml = f'{wirehtml}<tr>'
|
wirehtml = f'{wirehtml}<tr>'
|
||||||
for bla in p:
|
for cell in wirerow:
|
||||||
wirehtml = wirehtml + f'<td>{bla}</td>'
|
wirehtml = wirehtml + f'<td>{cell}</td>'
|
||||||
wirehtml = f'{wirehtml}</tr>'
|
wirehtml = f'{wirehtml}</tr>'
|
||||||
if isinstance(cable.shield, str):
|
if isinstance(cable.shield, str):
|
||||||
# shield is shown with specified color and black borders
|
# shield is shown with specified color and black borders
|
||||||
@ -221,7 +220,7 @@ class Harness:
|
|||||||
else:
|
else:
|
||||||
# shield is shown as a thin black wire
|
# shield is shown as a thin black wire
|
||||||
attributes = f'height="2" bgcolor="#000000" border="0"'
|
attributes = f'height="2" bgcolor="#000000" border="0"'
|
||||||
wirehtml = f'{wirehtml}<tr><td colspan="{len(p)}" cellpadding="0" {attributes} port="ws"></td></tr>'
|
wirehtml = f'{wirehtml}<tr><td colspan="{len(wirerow)}" cellpadding="0" {attributes} port="ws"></td></tr>'
|
||||||
|
|
||||||
wirehtml = f'{wirehtml}<tr><td> </td></tr>'
|
wirehtml = f'{wirehtml}<tr><td> </td></tr>'
|
||||||
wirehtml = f'{wirehtml}</table>'
|
wirehtml = f'{wirehtml}</table>'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user