Implement changes suggested by @kvid
This commit is contained in:
parent
711704dde9
commit
4eea76736f
@ -120,30 +120,18 @@ class Connector:
|
|||||||
raise Exception('Connectors with style set to simple may only have one pin')
|
raise Exception('Connectors with style set to simple may only have one pin')
|
||||||
self.pincount = 1
|
self.pincount = 1
|
||||||
|
|
||||||
if self.pincount is None:
|
if not self.pincount:
|
||||||
if self.pinlabels:
|
if not self.pins and not self.pinlabels:
|
||||||
self.pincount = len(self.pinlabels)
|
|
||||||
elif self.pins:
|
|
||||||
self.pincount = len(self.pins)
|
|
||||||
else:
|
|
||||||
raise Exception('You need to specify at least one, pincount, pins or pinlabels')
|
raise Exception('You need to specify at least one, pincount, pins or pinlabels')
|
||||||
|
self.pincount = max(len(self.pins), len(self.pinlabels), len(self.pincolors))
|
||||||
if self.pinlabels and self.pins:
|
|
||||||
if len(self.pinlabels) != len(self.pins):
|
|
||||||
raise Exception('Given pins and pinlabels size mismatch')
|
|
||||||
|
|
||||||
# create default lists for pins (sequential) and pinlabels (blank) if not specified
|
# create default lists for pins (sequential) and pinlabels (blank) if not specified
|
||||||
if not self.pins:
|
if not self.pins:
|
||||||
self.pins = list(range(1, self.pincount + 1))
|
self.pins = list(range(1, self.pincount + 1))
|
||||||
if not self.pinlabels:
|
|
||||||
self.pinlabels = [''] * self.pincount
|
|
||||||
|
|
||||||
if len(self.pins) != len(set(self.pins)):
|
if len(self.pins) != len(set(self.pins)):
|
||||||
raise Exception('Pins are not unique')
|
raise Exception('Pins are not unique')
|
||||||
|
|
||||||
if self.pincolors:
|
|
||||||
self.pincolors.extend([None] * (len(self.pins) - len(self.pincolors))) # autofill missing pincolors as 'no color'
|
|
||||||
|
|
||||||
if self.show_name is None:
|
if self.show_name is None:
|
||||||
self.show_name = not self.autogenerate # hide auto-generated designators by default
|
self.show_name = not self.autogenerate # hide auto-generated designators by default
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, \
|
|||||||
from collections import Counter
|
from collections import Counter
|
||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from itertools import zip_longest
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
@ -110,9 +111,7 @@ class Harness:
|
|||||||
pinhtml = []
|
pinhtml = []
|
||||||
pinhtml.append('<table border="0" cellspacing="0" cellpadding="3" cellborder="1">')
|
pinhtml.append('<table border="0" cellspacing="0" cellpadding="3" cellborder="1">')
|
||||||
|
|
||||||
for pin, pinlabel, pincolor in zip(connector.pins,
|
for pin, pinlabel, pincolor in zip_longest(connector.pins, connector.pinlabels, connector.pincolors):
|
||||||
connector.pinlabels,
|
|
||||||
connector.pincolors if connector.pincolors else [None] * len(connector.pins)):
|
|
||||||
if connector.hide_disconnected_pins and not connector.visible_pins.get(pin, False):
|
if connector.hide_disconnected_pins and not connector.visible_pins.get(pin, False):
|
||||||
continue
|
continue
|
||||||
pinhtml.append(' <tr>')
|
pinhtml.append(' <tr>')
|
||||||
@ -125,8 +124,7 @@ class Harness:
|
|||||||
pinhtml.append(f' <td sides="tbl">{pincolor}</td>')
|
pinhtml.append(f' <td sides="tbl">{pincolor}</td>')
|
||||||
pinhtml.append(f' <td sides="tbr"><table border="0" cellborder="1"><tr><td bgcolor="{wv_colors.translate_color(pincolor, "HEX")}" width="8" height="8" fixedsize="true"></td></tr></table></td>')
|
pinhtml.append(f' <td sides="tbr"><table border="0" cellborder="1"><tr><td bgcolor="{wv_colors.translate_color(pincolor, "HEX")}" width="8" height="8" fixedsize="true"></td></tr></table></td>')
|
||||||
else:
|
else:
|
||||||
pinhtml.append(f'<td sides="tbl"></td>')
|
pinhtml.append(f' <td colspan="2"></td>')
|
||||||
pinhtml.append(f'<td sides="tbr"></td>')
|
|
||||||
|
|
||||||
if connector.ports_right:
|
if connector.ports_right:
|
||||||
pinhtml.append(f' <td port="p{pin}r">{pin}</td>')
|
pinhtml.append(f' <td port="p{pin}r">{pin}</td>')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user