Add supplier and spn fields
This commit is contained in:
parent
92354e6852
commit
2d5a3c6e38
@ -101,6 +101,8 @@ class AdditionalComponent:
|
|||||||
subtype: Optional[MultilineHypertext] = None
|
subtype: Optional[MultilineHypertext] = None
|
||||||
manufacturer: Optional[MultilineHypertext] = None
|
manufacturer: Optional[MultilineHypertext] = None
|
||||||
mpn: Optional[MultilineHypertext] = None
|
mpn: Optional[MultilineHypertext] = None
|
||||||
|
supplier: Optional[MultilineHypertext] = None
|
||||||
|
spn: Optional[MultilineHypertext] = None
|
||||||
pn: Optional[Hypertext] = None
|
pn: Optional[Hypertext] = None
|
||||||
qty: float = 1
|
qty: float = 1
|
||||||
unit: Optional[str] = None
|
unit: Optional[str] = None
|
||||||
@ -116,6 +118,8 @@ class Connector:
|
|||||||
name: Designator
|
name: Designator
|
||||||
manufacturer: Optional[MultilineHypertext] = None
|
manufacturer: Optional[MultilineHypertext] = None
|
||||||
mpn: Optional[MultilineHypertext] = None
|
mpn: Optional[MultilineHypertext] = None
|
||||||
|
supplier: Optional[MultilineHypertext] = None
|
||||||
|
spn: Optional[MultilineHypertext] = None
|
||||||
pn: Optional[Hypertext] = None
|
pn: Optional[Hypertext] = None
|
||||||
style: Optional[str] = None
|
style: Optional[str] = None
|
||||||
category: Optional[str] = None
|
category: Optional[str] = None
|
||||||
@ -198,6 +202,8 @@ class Cable:
|
|||||||
name: Designator
|
name: Designator
|
||||||
manufacturer: Union[MultilineHypertext, List[MultilineHypertext], None] = None
|
manufacturer: Union[MultilineHypertext, List[MultilineHypertext], None] = None
|
||||||
mpn: Union[MultilineHypertext, List[MultilineHypertext], None] = None
|
mpn: Union[MultilineHypertext, List[MultilineHypertext], None] = None
|
||||||
|
supplier: Union[MultilineHypertext, List[MultilineHypertext], None] = None
|
||||||
|
spn: Union[MultilineHypertext, List[MultilineHypertext], None] = None
|
||||||
pn: Union[Hypertext, List[Hypertext], None] = None
|
pn: Union[Hypertext, List[Hypertext], None] = None
|
||||||
category: Optional[str] = None
|
category: Optional[str] = None
|
||||||
type: Optional[MultilineHypertext] = None
|
type: Optional[MultilineHypertext] = None
|
||||||
@ -288,7 +294,7 @@ class Cable:
|
|||||||
raise Exception('"s" may not be used as a wire label for a shielded cable.')
|
raise Exception('"s" may not be used as a wire label for a shielded cable.')
|
||||||
|
|
||||||
# if lists of part numbers are provided check this is a bundle and that it matches the wirecount.
|
# if lists of part numbers are provided check this is a bundle and that it matches the wirecount.
|
||||||
for idfield in [self.manufacturer, self.mpn, self.pn]:
|
for idfield in [self.manufacturer, self.mpn, self.supplier, self.spn, self.pn]:
|
||||||
if isinstance(idfield, list):
|
if isinstance(idfield, list):
|
||||||
if self.category == "bundle":
|
if self.category == "bundle":
|
||||||
# check the length
|
# check the length
|
||||||
|
|||||||
@ -125,7 +125,8 @@ class Harness:
|
|||||||
|
|
||||||
rows = [[remove_links(connector.name) if connector.show_name else None],
|
rows = [[remove_links(connector.name) if connector.show_name else None],
|
||||||
[f'P/N: {remove_links(connector.pn)}' if connector.pn else None,
|
[f'P/N: {remove_links(connector.pn)}' if connector.pn else None,
|
||||||
html_line_breaks(manufacturer_info_field(connector.manufacturer, connector.mpn))],
|
html_line_breaks(manufacturer_info_field(connector.manufacturer, connector.mpn)),
|
||||||
|
html_line_breaks(manufacturer_info_field(connector.supplier, connector.spn))],
|
||||||
[html_line_breaks(connector.type),
|
[html_line_breaks(connector.type),
|
||||||
html_line_breaks(connector.subtype),
|
html_line_breaks(connector.subtype),
|
||||||
f'{connector.pincount}-pin' if connector.show_pincount else None,
|
f'{connector.pincount}-pin' if connector.show_pincount else None,
|
||||||
@ -210,7 +211,10 @@ class Harness:
|
|||||||
[f'P/N: {remove_links(cable.pn)}' if (cable.pn and not isinstance(cable.pn, list)) else None,
|
[f'P/N: {remove_links(cable.pn)}' if (cable.pn and not isinstance(cable.pn, list)) else None,
|
||||||
html_line_breaks(manufacturer_info_field(
|
html_line_breaks(manufacturer_info_field(
|
||||||
cable.manufacturer if not isinstance(cable.manufacturer, list) else None,
|
cable.manufacturer if not isinstance(cable.manufacturer, list) else None,
|
||||||
cable.mpn if not isinstance(cable.mpn, list) else None))],
|
cable.mpn if not isinstance(cable.mpn, list) else None)),
|
||||||
|
html_line_breaks(manufacturer_info_field(
|
||||||
|
cable.supplier if not isinstance(cable.supplier, list) else None,
|
||||||
|
cable.spn if not isinstance(cable.spn, list) else None))],
|
||||||
[html_line_breaks(cable.type),
|
[html_line_breaks(cable.type),
|
||||||
f'{cable.wirecount}x' if cable.show_wirecount else None,
|
f'{cable.wirecount}x' if cable.show_wirecount else None,
|
||||||
f'{cable.gauge} {cable.gauge_unit}{awg_fmt}' if cable.gauge else None,
|
f'{cable.gauge} {cable.gauge_unit}{awg_fmt}' if cable.gauge else None,
|
||||||
@ -266,8 +270,13 @@ class Harness:
|
|||||||
manufacturer_info = manufacturer_info_field(
|
manufacturer_info = manufacturer_info_field(
|
||||||
cable.manufacturer[i - 1] if isinstance(cable.manufacturer, list) else None,
|
cable.manufacturer[i - 1] if isinstance(cable.manufacturer, list) else None,
|
||||||
cable.mpn[i - 1] if isinstance(cable.mpn, list) else None)
|
cable.mpn[i - 1] if isinstance(cable.mpn, list) else None)
|
||||||
|
supplier_info = manufacturer_info_field(
|
||||||
|
cable.supplier[i - 1] if isinstance(cable.supplier, list) else None,
|
||||||
|
cable.spn[i - 1] if isinstance(cable.spn, list) else None)
|
||||||
if manufacturer_info:
|
if manufacturer_info:
|
||||||
wireidentification.append(html_line_breaks(manufacturer_info))
|
wireidentification.append(html_line_breaks(manufacturer_info))
|
||||||
|
if supplier_info:
|
||||||
|
wireidentification.append(html_line_breaks(supplier_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.append(' <tr><td colspan="3">')
|
wirehtml.append(' <tr><td colspan="3">')
|
||||||
|
|||||||
@ -11,7 +11,7 @@ from wireviz.wv_gv_html import html_line_breaks
|
|||||||
from wireviz.wv_helper import clean_whitespace
|
from wireviz.wv_helper import clean_whitespace
|
||||||
|
|
||||||
BOM_COLUMNS_ALWAYS = ('id', 'description', 'qty', 'unit', 'designators')
|
BOM_COLUMNS_ALWAYS = ('id', 'description', 'qty', 'unit', 'designators')
|
||||||
BOM_COLUMNS_OPTIONAL = ('pn', 'manufacturer', 'mpn')
|
BOM_COLUMNS_OPTIONAL = ('pn', 'manufacturer', 'mpn', 'supplier', 'spn')
|
||||||
BOM_COLUMNS_IN_KEY = ('description', 'unit') + BOM_COLUMNS_OPTIONAL
|
BOM_COLUMNS_IN_KEY = ('description', 'unit') + BOM_COLUMNS_OPTIONAL
|
||||||
|
|
||||||
BOMKey = Tuple[str, ...]
|
BOMKey = Tuple[str, ...]
|
||||||
@ -144,7 +144,8 @@ def bom_list(bom: List[BOMEntry]) -> List[List[str]]:
|
|||||||
# Headers not specified here are generated by capitilising the internal name.
|
# Headers not specified here are generated by capitilising the internal name.
|
||||||
bom_headings = {
|
bom_headings = {
|
||||||
"pn": "P/N",
|
"pn": "P/N",
|
||||||
"mpn": "MPN"
|
"mpn": "MPN",
|
||||||
|
"spn": "SPN"
|
||||||
}
|
}
|
||||||
return ([[bom_headings.get(k, k.capitalize()) for k in keys]] + # Create header row with key names
|
return ([[bom_headings.get(k, k.capitalize()) for k in keys]] + # Create header row with key names
|
||||||
[[make_str(entry.get(k)) for k in keys] for entry in bom]) # Create string list for each entry row
|
[[make_str(entry.get(k)) for k in keys] for entry in bom]) # Create string list for each entry row
|
||||||
@ -156,16 +157,18 @@ def component_table_entry(
|
|||||||
pn: Optional[str] = None,
|
pn: Optional[str] = None,
|
||||||
manufacturer: Optional[str] = None,
|
manufacturer: Optional[str] = None,
|
||||||
mpn: Optional[str] = None,
|
mpn: Optional[str] = None,
|
||||||
|
supplier: Optional[str] = None,
|
||||||
|
spn: Optional[str] = None,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Return a diagram node table row string with an additional component."""
|
"""Return a diagram node table row string with an additional component."""
|
||||||
manufacturer_str = manufacturer_info_field(manufacturer, mpn)
|
manufacturer_str = manufacturer_info_field(manufacturer, mpn)
|
||||||
|
supplier_str = manufacturer_info_field(supplier, spn)
|
||||||
|
part_number_list = [pn, manufacturer_str, supplier_str]
|
||||||
output = (f'{qty}'
|
output = (f'{qty}'
|
||||||
+ (f' {unit}' if unit else '')
|
+ (f' {unit}' if unit else '')
|
||||||
+ f' x {type}'
|
+ f' x {type}'
|
||||||
+ ('<br/>' if pn or manufacturer_str else '')
|
+ ('<br/>' if any([part_number_list]) else '')
|
||||||
+ (f'P/N: {pn}' if pn else '')
|
+ (', '.join([x for x in part_number_list if x])))
|
||||||
+ (', ' if pn and manufacturer_str else '')
|
|
||||||
+ (manufacturer_str or ''))
|
|
||||||
# format the above output as left aligned text in a single visible cell
|
# format the above output as left aligned text in a single visible cell
|
||||||
# indent is set to two to match the indent in the generated html table
|
# indent is set to two to match the indent in the generated html table
|
||||||
return f'''<table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>
|
return f'''<table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user