Clean up arrow stuff
This commit is contained in:
parent
7eccbe4809
commit
347f7dbd56
@ -17,9 +17,7 @@ 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
|
||||||
from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, flatten2d, \
|
from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, flatten2d, \
|
||||||
open_file_read, open_file_write
|
open_file_read, open_file_write, is_arrow
|
||||||
|
|
||||||
arrows = ['<--','<->','-->','<==','<=>','==>']
|
|
||||||
|
|
||||||
class Harness:
|
class Harness:
|
||||||
|
|
||||||
@ -70,7 +68,7 @@ class Harness:
|
|||||||
raise Exception(f'{name}:{pin} not found.')
|
raise Exception(f'{name}:{pin} not found.')
|
||||||
|
|
||||||
# check via cable
|
# check via cable
|
||||||
if via_name in arrows:
|
if is_arrow(via_name):
|
||||||
if '-' in via_name:
|
if '-' in via_name:
|
||||||
self.mates[(from_name, from_pin, to_name, to_pin)] = via_name
|
self.mates[(from_name, from_pin, to_name, to_pin)] = via_name
|
||||||
elif '=' in via_name:
|
elif '=' in via_name:
|
||||||
|
|||||||
@ -14,7 +14,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
from wireviz import __version__
|
from wireviz import __version__
|
||||||
from wireviz.Harness import Harness
|
from wireviz.Harness import Harness
|
||||||
from wireviz.wv_helper import expand, open_file_read, isarrow, get_single_key_and_value
|
from wireviz.wv_helper import expand, open_file_read, is_arrow, get_single_key_and_value
|
||||||
|
|
||||||
|
|
||||||
def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, str, Tuple[str]) = None) -> Any:
|
def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, str, Tuple[str]) = None) -> Any:
|
||||||
@ -193,7 +193,7 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st
|
|||||||
check_type(designator, template, 'cable/arrow')
|
check_type(designator, template, 'cable/arrow')
|
||||||
harness.add_cable(name = designator, **template_cables[template])
|
harness.add_cable(name = designator, **template_cables[template])
|
||||||
|
|
||||||
elif isarrow(designator):
|
elif is_arrow(designator):
|
||||||
check_type(designator, template, 'cable/arrow')
|
check_type(designator, template, 'cable/arrow')
|
||||||
# arrows do not need to be generated here
|
# arrows do not need to be generated here
|
||||||
else:
|
else:
|
||||||
@ -223,7 +223,7 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st
|
|||||||
to_name, to_pin = get_single_key_and_value(connection_set[index_entry][index_item+1])
|
to_name, to_pin = get_single_key_and_value(connection_set[index_entry][index_item+1])
|
||||||
harness.connect(from_name, from_pin, via_name, via_pin, to_name, to_pin)
|
harness.connect(from_name, from_pin, via_name, via_pin, to_name, to_pin)
|
||||||
|
|
||||||
elif isarrow(designator):
|
elif is_arrow(designator):
|
||||||
if index_item == 0: # list starts with an arrow
|
if index_item == 0: # list starts with an arrow
|
||||||
raise Exception('An arrow cannot be at the start of a connection set')
|
raise Exception('An arrow cannot be at the start of a connection set')
|
||||||
elif index_item == len(entry) - 1: # list ends with an arrow
|
elif index_item == len(entry) - 1: # list ends with an arrow
|
||||||
|
|||||||
@ -112,7 +112,7 @@ def open_file_write(filename):
|
|||||||
def open_file_append(filename):
|
def open_file_append(filename):
|
||||||
return open(filename, 'a', encoding='UTF-8')
|
return open(filename, 'a', encoding='UTF-8')
|
||||||
|
|
||||||
def isarrow(inp):
|
def is_arrow(inp):
|
||||||
"""
|
"""
|
||||||
Matches strings of one or multiple `-` or `=` (but not mixed)
|
Matches strings of one or multiple `-` or `=` (but not mixed)
|
||||||
optionally starting with `<` and/or ending with `>`.
|
optionally starting with `<` and/or ending with `>`.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user