Merge changes to ferrule code generation
This commit is contained in:
commit
c2fa1d09e7
@ -59,42 +59,27 @@ class Harness:
|
|||||||
|
|
||||||
for key, connector in self.connectors.items():
|
for key, connector in self.connectors.items():
|
||||||
if connector.category == 'ferrule':
|
if connector.category == 'ferrule':
|
||||||
subtype = f', {connector.subtype}' if connector.subtype else ''
|
|
||||||
color = wv_colors.translate_color(connector.color, self.color_mode) if connector.color else ''
|
|
||||||
infostring = f'{connector.type}{subtype} {color}'
|
|
||||||
|
|
||||||
# id = identification
|
rows = [[connector.type, connector.subtype, connector.color, '<!-- colorbar -->' if connector.color else None],
|
||||||
identification = [connector.manufacturer,
|
[connector.manufacturer,
|
||||||
f'MPN: {connector.manufacturer_part_number}' if connector.manufacturer_part_number else '',
|
f'MPN: {connector.manufacturer_part_number}' if connector.manufacturer_part_number else None,
|
||||||
f'IPN: {connector.internal_part_number}' if connector.internal_part_number else '']
|
f'IPN: {connector.internal_part_number}' if connector.internal_part_number else None]]
|
||||||
identification = list(filter(None, identification))
|
rows = [list(filter(None, row)) for row in rows] # remove missing attributes
|
||||||
if(len(identification) > 0):
|
|
||||||
infostring = f'{infostring}<br/>'
|
|
||||||
for attrib in identification:
|
|
||||||
infostring = f'{infostring}{attrib}, '
|
|
||||||
infostring = infostring[:-2] # remove trainling comma and space
|
|
||||||
|
|
||||||
infostring = html_line_breaks(infostring)
|
html = '<table border="0" cellspacing="0" cellpadding="0">'
|
||||||
|
for row in rows:
|
||||||
|
if len(row) > 0:
|
||||||
|
html = f'{html}<tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>'
|
||||||
|
for cell in row:
|
||||||
|
html = f'{html}<td>{cell}</td>'
|
||||||
|
html = f'{html}</tr></table></td></tr>'
|
||||||
|
html = f'{html}</table>'
|
||||||
|
|
||||||
infostring_l = infostring if connector.ports_right else ''
|
if connector.color: # add color bar next to color info, if present
|
||||||
infostring_r = infostring if connector.ports_left else ''
|
colorbar = f'<td bgcolor="{wv_colors.translate_color(connector.color, "HEX")}" width="4"></td>'
|
||||||
|
html = html.replace('<td><!-- colorbar --></td>', colorbar)
|
||||||
|
|
||||||
# INFO: Leaving this one as a string.format form because f-strings do not work well with triple quotes
|
dot.node(key, label=f'<{html}>', shape='none', margin='0', style='filled', fillcolor='white')
|
||||||
colorbar = f'<TD BGCOLOR="{wv_colors.translate_color(connector.color, "HEX")}" BORDER="1" SIDES="LR" WIDTH="4"></TD>' if connector.color else ''
|
|
||||||
dot.node(key, shape='none',
|
|
||||||
style='filled',
|
|
||||||
margin='0',
|
|
||||||
orientation='0' if connector.ports_left else '180',
|
|
||||||
label='''<
|
|
||||||
|
|
||||||
<TABLE BORDER="1" CELLBORDER="0" CELLSPACING="0" CELLPADDING="2"><TR>
|
|
||||||
<TD PORT="p1l"> {infostring_l} </TD>
|
|
||||||
{colorbar}
|
|
||||||
<TD PORT="p1r"> {infostring_r} </TD>
|
|
||||||
</TR></TABLE>
|
|
||||||
|
|
||||||
|
|
||||||
>'''.format(infostring_l=infostring_l, infostring_r=infostring_r, colorbar=colorbar))
|
|
||||||
|
|
||||||
else: # not a ferrule
|
else: # not a ferrule
|
||||||
identification = [connector.manufacturer,
|
identification = [connector.manufacturer,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user