Use constant identifiers instead of repeating literals
Co-authored-by: kvid <kvid@users.noreply.github.com>
This commit is contained in:
parent
7bd52b77e4
commit
2e56f82988
@ -125,8 +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(pn_info_string("mpn", connector.manufacturer, connector.mpn)),
|
html_line_breaks(pn_info_string(HDR_MPN, connector.manufacturer, connector.mpn)),
|
||||||
html_line_breaks(pn_info_string("spn", connector.supplier, connector.spn))],
|
html_line_breaks(pn_info_string(HDR_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 +209,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("mpn",
|
html_line_breaks(pn_info_string(HDR_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("spn",
|
html_line_breaks(pn_info_string(HDR_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 +267,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("mpn",
|
manufacturer_info = pn_info_string(HDR_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("spn",
|
supplier_info = pn_info_string(HDR_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:
|
||||||
|
|||||||
@ -144,8 +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": HDR_MPN,
|
||||||
"spn": "SPN"
|
"spn": HDR_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
|
||||||
@ -161,9 +161,11 @@ def component_table_entry(
|
|||||||
spn: 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 = pn_info_string("mpn", manufacturer, mpn)
|
part_number_list = [
|
||||||
supplier_str = pn_info_string("spn", supplier, spn)
|
pn,
|
||||||
part_number_list = [pn, manufacturer_str, supplier_str]
|
pn_info_string(HDR_MPN, manufacturer, mpn),
|
||||||
|
pn_info_string(HDR_SPN, supplier, spn),
|
||||||
|
]
|
||||||
output = (f'{qty}'
|
output = (f'{qty}'
|
||||||
+ (f' {unit}' if unit else '')
|
+ (f' {unit}' if unit else '')
|
||||||
+ f' x {type}'
|
+ f' x {type}'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user