Remove input text hyperlinks except in the HTML BOM
GraphViz does not support the a HTML tag when generating the tables for the cables/connectors, so this change will remove these tags for the graph generation. However for the HTML BOM output table these links will be generated.
This commit is contained in:
parent
e85ee5d285
commit
e2e8bbfb91
@ -1,7 +1,7 @@
|
|||||||
# daisy chain, variant 1
|
# daisy chain, variant 1
|
||||||
templates:
|
templates:
|
||||||
- &template_con
|
- &template_con
|
||||||
type: Molex KK 254
|
type: '<a href="https://www.molex.com/molex/products/family/kk_254_rpc_connector_system">Molex KK 254</a>'
|
||||||
subtype: female
|
subtype: female
|
||||||
pinlabels: [GND, VCC, SCL, SDA]
|
pinlabels: [GND, VCC, SCL, SDA]
|
||||||
- &template_wire
|
- &template_wire
|
||||||
|
|||||||
@ -8,7 +8,7 @@ from wireviz.wv_colors import get_color_hex
|
|||||||
from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, \
|
from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, \
|
||||||
nested_html_table, flatten2d, index_if_list, html_line_breaks, \
|
nested_html_table, flatten2d, index_if_list, html_line_breaks, \
|
||||||
clean_whitespace, open_file_read, open_file_write, html_colorbar, \
|
clean_whitespace, open_file_read, open_file_write, html_colorbar, \
|
||||||
html_image, html_caption, manufacturer_info_field, component_table_entry
|
html_image, html_caption, manufacturer_info_field, component_table_entry, remove_links
|
||||||
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
|
||||||
@ -92,8 +92,8 @@ class Harness:
|
|||||||
|
|
||||||
html = []
|
html = []
|
||||||
|
|
||||||
rows = [[connector.name if connector.show_name else None],
|
rows = [[remove_links(connector.name) if connector.show_name else None],
|
||||||
[f'P/N: {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(connector.type),
|
[html_line_breaks(connector.type),
|
||||||
html_line_breaks(connector.subtype),
|
html_line_breaks(connector.subtype),
|
||||||
@ -162,8 +162,8 @@ class Harness:
|
|||||||
elif cable.gauge_unit.upper() == 'AWG':
|
elif cable.gauge_unit.upper() == 'AWG':
|
||||||
awg_fmt = f' ({mm2_equiv(cable.gauge)} mm\u00B2)'
|
awg_fmt = f' ({mm2_equiv(cable.gauge)} mm\u00B2)'
|
||||||
|
|
||||||
rows = [[cable.name if cable.show_name else None],
|
rows = [[remove_links(cable.name) if cable.show_name else None],
|
||||||
[f'P/N: {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))],
|
||||||
@ -205,7 +205,7 @@ class Harness:
|
|||||||
# create a list of wire parameters
|
# create a list of wire parameters
|
||||||
wireidentification = []
|
wireidentification = []
|
||||||
if isinstance(cable.pn, list):
|
if isinstance(cable.pn, list):
|
||||||
wireidentification.append(f'P/N: {cable.pn[i - 1]}')
|
wireidentification.append(f'P/N: {remove_links(cable.pn[i - 1])}')
|
||||||
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)
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
from wireviz import wv_colors
|
from wireviz import wv_colors
|
||||||
from typing import List
|
from typing import List
|
||||||
|
import re
|
||||||
|
|
||||||
awg_equiv_table = {
|
awg_equiv_table = {
|
||||||
'0.09': '28',
|
'0.09': '28',
|
||||||
@ -136,15 +137,18 @@ def tuplelist2tsv(inp, header=None):
|
|||||||
inp.insert(0, header)
|
inp.insert(0, header)
|
||||||
inp = flatten2d(inp)
|
inp = flatten2d(inp)
|
||||||
for row in inp:
|
for row in inp:
|
||||||
output = output + '\t'.join(str(item) for item in row) + '\n'
|
output = output + '\t'.join(str(remove_links(item)) for item in row) + '\n'
|
||||||
return output
|
return output
|
||||||
|
|
||||||
# Return the value indexed if it is a list, or simply the value otherwise.
|
# Return the value indexed if it is a list, or simply the value otherwise.
|
||||||
def index_if_list(value, index):
|
def index_if_list(value, index):
|
||||||
return value[index] if isinstance(value, list) else value
|
return value[index] if isinstance(value, list) else value
|
||||||
|
|
||||||
|
def remove_links(inp):
|
||||||
|
return re.sub(r'<[aA] [^>]*>([^<]*)</[aA]>', r'\1', inp) if isinstance(inp, str) else inp
|
||||||
|
|
||||||
def html_line_breaks(inp):
|
def html_line_breaks(inp):
|
||||||
return inp.replace('\n', '<br />') if isinstance(inp, str) else inp
|
return remove_links(inp).replace('\n', '<br />') if isinstance(inp, str) else inp
|
||||||
|
|
||||||
def clean_whitespace(inp):
|
def clean_whitespace(inp):
|
||||||
return ' '.join(inp.split()).replace(' ,', ',') if isinstance(inp, str) else inp
|
return ' '.join(inp.split()).replace(' ,', ',') if isinstance(inp, str) else inp
|
||||||
|
|||||||
@ -3,8 +3,8 @@ connectors:
|
|||||||
type: Molex KK 254
|
type: Molex KK 254
|
||||||
pincount: 4
|
pincount: 4
|
||||||
subtype: female
|
subtype: female
|
||||||
manufacturer: Molex # set manufacter name
|
manufacturer: '<a href="https://www.molex.com/">Molex</a>' # set manufacter name
|
||||||
mpn: 22013047 # set manufacturer part number
|
mpn: '<a href="https://www.molex.com/molex/products/part-detail/crimp_housings/0022013047">22013047</a>' # set manufacturer part number
|
||||||
# add a list of additional components to a part (shown in graph)
|
# add a list of additional components to a part (shown in graph)
|
||||||
additional_components:
|
additional_components:
|
||||||
-
|
-
|
||||||
@ -63,6 +63,6 @@ additional_bom_items:
|
|||||||
designators:
|
designators:
|
||||||
- X2
|
- X2
|
||||||
- X3
|
- X3
|
||||||
manufacturer: generic company
|
manufacturer: '<a href="https://www.bradyid.com">Brady</a>'
|
||||||
mpn: Label1
|
mpn: '<a href="https://www.bradyid.com/wire-cable-labels/bmp71-bmp61-m611-tls-2200-nylon-cloth-wire-general-id-labels-cps-2958789">B-499</a>'
|
||||||
pn: Label-ID-1
|
pn: Label-ID-1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user