Create bom_bubble() function

This commit is contained in:
Daniel Rojas 2021-03-23 11:00:26 +01:00
parent 8c26c8fbbd
commit e61d14ba43
3 changed files with 7 additions and 4 deletions

View File

@ -12,7 +12,7 @@ from wireviz import wv_colors, __version__, APP_NAME, APP_URL
from wireviz.DataClasses import Connector, Cable from wireviz.DataClasses import Connector, Cable
from wireviz.wv_colors import get_color_hex from wireviz.wv_colors import get_color_hex
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, bom_bubble
from wireviz.wv_bom import manufacturer_info_field, component_table_entry, \ from wireviz.wv_bom import manufacturer_info_field, component_table_entry, \
get_additional_component_table, bom_list, generate_bom get_additional_component_table, bom_list, generate_bom
from wireviz.wv_html import generate_html_output from wireviz.wv_html import generate_html_output
@ -115,7 +115,7 @@ class Harness:
html = [] html = []
rows = [[remove_links(connector.name) if connector.show_name else None], rows = [[remove_links(connector.name) if connector.show_name else None],
['<BOM Number>' if self.show_bom_item_numbers else None, # TODO: Show actual BOM number [bom_bubble('###') if self.show_bom_item_numbers else None, # TODO: Show actual BOM number
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,

View File

@ -6,7 +6,7 @@ from itertools import groupby
from typing import Any, Dict, List, Optional, Tuple, Union from typing import Any, Dict, List, Optional, Tuple, Union
from wireviz.DataClasses import AdditionalComponent, Connector, Cable from wireviz.DataClasses import AdditionalComponent, Connector, Cable
from wireviz.wv_gv_html import html_line_breaks from wireviz.wv_gv_html import html_line_breaks, bom_bubble
from wireviz.wv_helper import clean_whitespace from wireviz.wv_helper import clean_whitespace
BOMColumn = str # = Literal['id', 'description', 'qty', 'unit', 'designators', 'pn', 'manufacturer', 'mpn'] BOMColumn = str # = Literal['id', 'description', 'qty', 'unit', 'designators', 'pn', 'manufacturer', 'mpn']
@ -35,7 +35,7 @@ def get_additional_component_table(harness: "Harness", component: Union[Connecto
manufacturer_str = manufacturer_info_field(part.manufacturer, part.mpn) manufacturer_str = manufacturer_info_field(part.manufacturer, part.mpn)
columns = [] columns = []
if harness.show_bom_item_numbers: if harness.show_bom_item_numbers:
columns.append(f'<table border="0"><tr><td border="1" style="rounded">{id}</td></tr></table>') columns.append(bom_bubble(id))
columns.append(f'{part.qty}' + (f' {part.unit}' if part.unit else ' x')) columns.append(f'{part.qty}' + (f' {part.unit}' if part.unit else ' x'))
columns.append(f'{part.type}') columns.append(f'{part.type}')
if harness.show_part_numbers: if harness.show_part_numbers:

View File

@ -64,3 +64,6 @@ def html_size_attr(image):
def html_line_breaks(inp): def html_line_breaks(inp):
return remove_links(inp).replace('\n', '<br />') if isinstance(inp, str) else inp return remove_links(inp).replace('\n', '<br />') if isinstance(inp, str) else inp
def bom_bubble(inp):
return(f'<table border="0"><tr><td border="1" style="rounded">{inp}</td></tr></table>')