Apply options.color_mode where showing color as text
This commit is contained in:
parent
2d6b1e35e4
commit
09243fb964
@ -11,7 +11,7 @@ import re
|
|||||||
|
|
||||||
from wireviz import wv_colors, __version__, APP_NAME, APP_URL
|
from wireviz import wv_colors, __version__, APP_NAME, APP_URL
|
||||||
from wireviz.DataClasses import Metadata, Options, Connector, Cable
|
from wireviz.DataClasses import Metadata, Options, Connector, Cable
|
||||||
from wireviz.wv_colors import get_color_hex
|
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 manufacturer_info_field, component_table_entry, \
|
from wireviz.wv_bom import manufacturer_info_field, component_table_entry, \
|
||||||
@ -128,7 +128,8 @@ class Harness:
|
|||||||
[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,
|
||||||
connector.color, html_colorbar(connector.color)],
|
translate_color(connector.color, self.options.color_mode) if connector.color else None,
|
||||||
|
html_colorbar(connector.color)],
|
||||||
'<!-- connector table -->' if connector.style != 'simple' else None,
|
'<!-- connector table -->' if connector.style != 'simple' else None,
|
||||||
[html_image(connector.image)],
|
[html_image(connector.image)],
|
||||||
[html_caption(connector.image)]]
|
[html_caption(connector.image)]]
|
||||||
@ -150,7 +151,7 @@ class Harness:
|
|||||||
pinhtml.append(f' <td>{pinlabel}</td>')
|
pinhtml.append(f' <td>{pinlabel}</td>')
|
||||||
if connector.pincolors:
|
if connector.pincolors:
|
||||||
if pincolor in wv_colors._color_hex.keys():
|
if pincolor in wv_colors._color_hex.keys():
|
||||||
pinhtml.append(f' <td sides="tbl">{pincolor}</td>')
|
pinhtml.append(f' <td sides="tbl">{translate_color(pincolor, self.options.color_mode)}</td>')
|
||||||
pinhtml.append( ' <td sides="tbr">')
|
pinhtml.append( ' <td sides="tbr">')
|
||||||
pinhtml.append( ' <table border="0" cellborder="1"><tr>')
|
pinhtml.append( ' <table border="0" cellborder="1"><tr>')
|
||||||
pinhtml.append(f' <td bgcolor="{wv_colors.translate_color(pincolor, "HEX")}" width="8" height="8" fixedsize="true"></td>')
|
pinhtml.append(f' <td bgcolor="{wv_colors.translate_color(pincolor, "HEX")}" width="8" height="8" fixedsize="true"></td>')
|
||||||
@ -213,7 +214,8 @@ class Harness:
|
|||||||
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,
|
||||||
'+ S' if cable.shield else None,
|
'+ S' if cable.shield else None,
|
||||||
f'{cable.length} {cable.length_unit}' if cable.length > 0 else None,
|
f'{cable.length} {cable.length_unit}' if cable.length > 0 else None,
|
||||||
cable.color, html_colorbar(cable.color)],
|
translate_color(cable.color, self.options.color_mode) if cable.color else None,
|
||||||
|
html_colorbar(cable.color)],
|
||||||
'<!-- wire table -->',
|
'<!-- wire table -->',
|
||||||
[html_image(cable.image)],
|
[html_image(cable.image)],
|
||||||
[html_caption(cable.image)]]
|
[html_caption(cable.image)]]
|
||||||
|
|||||||
@ -6,6 +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_colors import translate_color
|
||||||
from wireviz.wv_gv_html import html_line_breaks
|
from wireviz.wv_gv_html import html_line_breaks
|
||||||
from wireviz.wv_helper import clean_whitespace
|
from wireviz.wv_helper import clean_whitespace
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ def generate_bom(harness: "Harness") -> List[BOMEntry]:
|
|||||||
+ (f', {connector.type}' if connector.type else '')
|
+ (f', {connector.type}' if connector.type else '')
|
||||||
+ (f', {connector.subtype}' if connector.subtype else '')
|
+ (f', {connector.subtype}' if connector.subtype else '')
|
||||||
+ (f', {connector.pincount} pins' if connector.show_pincount else '')
|
+ (f', {connector.pincount} pins' if connector.show_pincount else '')
|
||||||
+ (f', {connector.color}' if connector.color else ''))
|
+ (f', {translate_color(connector.color, harness.options.color_mode)}' if connector.color else ''))
|
||||||
bom_entries.append({
|
bom_entries.append({
|
||||||
'description': description, 'designators': connector.name if connector.show_name else None,
|
'description': description, 'designators': connector.name if connector.show_name else None,
|
||||||
**optional_fields(connector),
|
**optional_fields(connector),
|
||||||
@ -99,7 +100,7 @@ def generate_bom(harness: "Harness") -> List[BOMEntry]:
|
|||||||
description = ('Wire'
|
description = ('Wire'
|
||||||
+ (f', {cable.type}' if cable.type else '')
|
+ (f', {cable.type}' if cable.type else '')
|
||||||
+ (f', {cable.gauge} {cable.gauge_unit}' if cable.gauge else '')
|
+ (f', {cable.gauge} {cable.gauge_unit}' if cable.gauge else '')
|
||||||
+ (f', {color}' if color else ''))
|
+ (f', {translate_color(color, harness.options.color_mode)}' if color else ''))
|
||||||
bom_entries.append({
|
bom_entries.append({
|
||||||
'description': description, 'qty': cable.length, 'unit': cable.length_unit, 'designators': cable.name if cable.show_name else None,
|
'description': description, 'qty': cable.length, 'unit': cable.length_unit, 'designators': cable.name if cable.show_name else None,
|
||||||
**{k: index_if_list(v, index) for k, v in optional_fields(cable).items()},
|
**{k: index_if_list(v, index) for k, v in optional_fields(cable).items()},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user