Rename HDR_* to HEADER_*, fix missing P/N string in output
This commit is contained in:
parent
a30d26e6af
commit
07a6360c16
@ -15,7 +15,8 @@ from wireviz.wv_colors import get_color_hex, translate_color
|
|||||||
from wireviz.wv_gv_html import nested_html_table, html_colorbar, html_image, \
|
from wireviz.wv_gv_html import nested_html_table, html_colorbar, html_image, \
|
||||||
html_caption, remove_links, html_line_breaks
|
html_caption, remove_links, html_line_breaks
|
||||||
from wireviz.wv_bom import pn_info_string, component_table_entry, \
|
from wireviz.wv_bom import pn_info_string, component_table_entry, \
|
||||||
get_additional_component_table, bom_list, generate_bom
|
get_additional_component_table, bom_list, generate_bom, \
|
||||||
|
HEADER_MPN, HEADER_SPN
|
||||||
from wireviz.wv_html import generate_html_output
|
from wireviz.wv_html import generate_html_output
|
||||||
from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, flatten2d, \
|
from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, flatten2d, \
|
||||||
open_file_read, open_file_write
|
open_file_read, open_file_write
|
||||||
@ -125,8 +126,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(pn_info_string(HDR_MPN, connector.manufacturer, connector.mpn)),
|
html_line_breaks(pn_info_string(HEADER_MPN, connector.manufacturer, connector.mpn)),
|
||||||
html_line_breaks(pn_info_string(HDR_SPN, connector.supplier, connector.spn))],
|
html_line_breaks(pn_info_string(HEADER_SPN, 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,
|
||||||
@ -209,10 +210,10 @@ class Harness:
|
|||||||
|
|
||||||
rows = [[remove_links(cable.name) if cable.show_name else None],
|
rows = [[remove_links(cable.name) if cable.show_name else None],
|
||||||
[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(pn_info_string(HDR_MPN,
|
html_line_breaks(pn_info_string(HEADER_MPN,
|
||||||
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(pn_info_string(HDR_SPN,
|
html_line_breaks(pn_info_string(HEADER_SPN,
|
||||||
cable.supplier if not isinstance(cable.supplier, list) else None,
|
cable.supplier if not isinstance(cable.supplier, list) else None,
|
||||||
cable.spn if not isinstance(cable.spn, list) else None))],
|
cable.spn if not isinstance(cable.spn, list) else None))],
|
||||||
[html_line_breaks(cable.type),
|
[html_line_breaks(cable.type),
|
||||||
@ -267,10 +268,10 @@ class Harness:
|
|||||||
wireidentification = []
|
wireidentification = []
|
||||||
if isinstance(cable.pn, list):
|
if isinstance(cable.pn, list):
|
||||||
wireidentification.append(f'P/N: {remove_links(cable.pn[i - 1])}')
|
wireidentification.append(f'P/N: {remove_links(cable.pn[i - 1])}')
|
||||||
manufacturer_info = pn_info_string(HDR_MPN,
|
manufacturer_info = pn_info_string(HEADER_MPN,
|
||||||
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 = pn_info_string(HDR_SPN,
|
supplier_info = pn_info_string(HEADER_SPN,
|
||||||
cable.supplier[i - 1] if isinstance(cable.supplier, list) else None,
|
cable.supplier[i - 1] if isinstance(cable.supplier, list) else None,
|
||||||
cable.spn[i - 1] if isinstance(cable.spn, list) else None)
|
cable.spn[i - 1] if isinstance(cable.spn, list) else None)
|
||||||
if manufacturer_info:
|
if manufacturer_info:
|
||||||
|
|||||||
@ -14,6 +14,10 @@ BOM_COLUMNS_ALWAYS = ('id', 'description', 'qty', 'unit', 'designators')
|
|||||||
BOM_COLUMNS_OPTIONAL = ('pn', 'manufacturer', 'mpn', 'supplier', 'spn')
|
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
|
||||||
|
|
||||||
|
HEADER_PN = 'P/N'
|
||||||
|
HEADER_MPN = 'MPN'
|
||||||
|
HEADER_SPN = 'SPN'
|
||||||
|
|
||||||
BOMKey = Tuple[str, ...]
|
BOMKey = Tuple[str, ...]
|
||||||
BOMColumn = str # = Literal[*BOM_COLUMNS_ALWAYS, *BOM_COLUMNS_OPTIONAL]
|
BOMColumn = str # = Literal[*BOM_COLUMNS_ALWAYS, *BOM_COLUMNS_OPTIONAL]
|
||||||
BOMEntry = Dict[BOMColumn, Union[str, int, float, List[str], None]]
|
BOMEntry = Dict[BOMColumn, Union[str, int, float, List[str], None]]
|
||||||
@ -143,9 +147,9 @@ def bom_list(bom: List[BOMEntry]) -> List[List[str]]:
|
|||||||
# Custom mapping from internal name to BOM column headers.
|
# Custom mapping from internal name to BOM column headers.
|
||||||
# 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": HEADER_PN,
|
||||||
"mpn": HDR_MPN,
|
"mpn": HEADER_MPN,
|
||||||
"spn": HDR_SPN,
|
"spn": HEADER_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
|
||||||
@ -162,9 +166,9 @@ def component_table_entry(
|
|||||||
) -> str:
|
) -> str:
|
||||||
"""Return a diagram node table row string with an additional component."""
|
"""Return a diagram node table row string with an additional component."""
|
||||||
part_number_list = [
|
part_number_list = [
|
||||||
pn,
|
pn_info_string(HEADER_PN, None, pn),
|
||||||
pn_info_string(HDR_MPN, manufacturer, mpn),
|
pn_info_string(HEADER_MPN, manufacturer, mpn),
|
||||||
pn_info_string(HDR_SPN, supplier, spn),
|
pn_info_string(HEADER_SPN, supplier, spn),
|
||||||
]
|
]
|
||||||
output = (f'{qty}'
|
output = (f'{qty}'
|
||||||
+ (f' {unit}' if unit else '')
|
+ (f' {unit}' if unit else '')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user