Skip to content

Commit

Permalink
Remove any newlines in fields for BOM generation
Browse files Browse the repository at this point in the history
  • Loading branch information
formatc1702 committed Jul 5, 2020
1 parent d4ac4da commit 46ed241
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions src/wireviz/Harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from wireviz.DataClasses import Connector, Cable
from graphviz import Graph
from wireviz import wv_colors
from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, nested, flatten2d, index_if_list, html_line_breaks, graphviz_line_breaks
from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, nested, flatten2d, index_if_list, html_line_breaks, graphviz_line_breaks, remove_line_breaks
from collections import Counter
from typing import List

Expand Down Expand Up @@ -113,7 +113,6 @@ def create_graph(self):
pinouts[0].append(f'<p{pinnumber}l>{pinnumber}')
if connector.ports_right:
pinouts[2].append(f'<p{pinnumber}r>{pinnumber}')
print(attributes)
label = [connector.name if connector.show_name else '', identification, attributes, pinouts, graphviz_line_breaks(connector.notes)]
dot.node(key, label=nested(label))

Expand Down Expand Up @@ -324,8 +323,8 @@ def bom(self):
shared = next(iter(items.values()))
designators = list(items.keys())
designators.sort()
conn_type = f', {shared.type}' if shared.type else ''
conn_subtype = f', {shared.subtype}' if shared.subtype else ''
conn_type = f', {remove_line_breaks(shared.type)}' if shared.type else ''
conn_subtype = f', {remove_line_breaks(shared.subtype)}' if shared.subtype else ''
conn_pincount = f', {shared.pincount} pins' if shared.category != 'ferrule' else ''
conn_color = f', {shared.color}' if shared.color else ''
name = f'Connector{conn_type}{conn_subtype}{conn_pincount}{conn_color}'
Expand All @@ -344,7 +343,7 @@ def bom(self):
designators = list(items.keys())
designators.sort()
total_length = sum(i.length for i in items.values())
cable_type = f', {shared.type}' if shared.type else ''
cable_type = f', {remove_line_breaks(shared.type)}' if shared.type else ''
gauge_name = f' x {shared.gauge} {shared.gauge_unit}' if shared.gauge else ' wires'
shield_name = ' shielded' if shared.shield else ''
name = f'Cable{cable_type}, {shared.wirecount}{gauge_name}{shield_name}'
Expand All @@ -371,7 +370,7 @@ def bom(self):
designators = list(dict.fromkeys(designators)) # remove duplicates
designators.sort()
total_length = sum(i['length'] for i in items)
wire_type = f', {shared["type"]}' if 'type' in shared else ''
wire_type = f', {remove_line_breaks(shared["type"])}' if 'type' in shared else ''
gauge_name = f', {shared["gauge"]} {shared["gauge_unit"]}' if 'gauge' in shared else ''
gauge_color = f', {shared["color"]}' if 'color' in shared != '' else ''
name = f'Wire{wire_type}{gauge_name}{gauge_color}'
Expand Down
2 changes: 1 addition & 1 deletion src/wireviz/wv_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ def graphviz_line_breaks(inp):
return inp.replace('\n', '\\l') if isinstance(inp, str) else inp # \l generates left-aligned new lines. http://www.graphviz.org/doc/info/attrs.html#k:escString

def remove_line_breaks(inp):
return inp.replace('\n', ' ')
return inp.replace('\n', ' ').rstrip() if isinstance(inp, str) else inp

0 comments on commit 46ed241

Please sign in to comment.