diff options
Diffstat (limited to 'tableconversion.py')
-rw-r--r-- | tableconversion.py | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/tableconversion.py b/tableconversion.py index 1dedce1..71b56a5 100644 --- a/tableconversion.py +++ b/tableconversion.py @@ -44,7 +44,6 @@ def parse_wireviz_yml(file_path): connector2wpin = str(connection[2]) connector2 = connector2wpin[2:connector2wpin.find("':")] connector2pins = connector2wpin[connector2wpin.find(" [")+2:connector2wpin.rfind("]}")].split(",") - for pins in connector2pins: idcount=idcount+1 if pins.count("-") > 0: @@ -52,7 +51,6 @@ def parse_wireviz_yml(file_path): negativesign=0 for pin in pinrange: if str(connectors[connector]['pins']).count(pin) < 1: - print(pin) negativesign=1 if not negativesign: for x in range(int(pinrange[0]),int(pinrange[1])+1): @@ -65,13 +63,17 @@ def parse_wireviz_yml(file_path): ident = str(ord(connector[0]))[:1]+str(ord(str(connectorpinsadjusted[x])[-1]))[-1]+str(ord(str(connector2pinsadjusted[x])[-1]))[-1]+str(ord(wires[bundle]['colors'][x][0]))+str(idcount)[-1] ident = ident.strip(" ") pin1 = connectorpinsadjusted[x] - notes = "none" + pin2 = connector2pinsadjusted[x] + notes = "" if str(connectors[connector]).count("'pinlabels':"): - if str(connectors[connector]['pinlabels']).count(connectorpinsadjusted[x]): - stringarray= [str(x) for x in connectors[connector]['pinlabels']] - print(stringarray) - print(connectorpinsadjusted) - print(stringarray.index(connectorpinsadjusted[x].strip("\""))) + stringarray = list(map(str,connectors[connector]['pinlabels'])) + if stringarray.count(connectorpinsadjusted[x][1:-1]): + pin1= connectors[connector]['pins'][stringarray.index(connectorpinsadjusted[x][1:-1])] + if str(connectors[connector2.strip("'")]).count("'pinlabels':")and not(str(connector2pinsadjusted[x]).isnumeric()): + stringarray = list(map(str,connectors[connector2]['pinlabels'])) + print(connector2pinsadjusted) + if stringarray.count(connector2pinsadjusted[x].strip(" ")[1:-1]): + pin2= connectors[connector2]['pins'][stringarray.index(connector2pinsadjusted[x].strip(" ")[1:-1])] if str(wires[bundle]).find("'notes':") > 0: notes = wires[bundle]['notes'] wire_info.append({ @@ -82,7 +84,7 @@ def parse_wireviz_yml(file_path): 'Color': wires[bundle]['colors'][x], 'Gauge': wires[bundle]['gauge'], 'End 2': connector2, - 'Pin 2': connector2pinsadjusted[x], + 'Pin 2': pin2, 'Notes': notes, }) else: @@ -90,7 +92,11 @@ def parse_wireviz_yml(file_path): for x in range(0,len(connectorpinsadjusted)): ident = str(ord(connector[0]))[:1]+str(ord(str(connectorpinsadjusted[x])[-1]))[-1]+"0"+str(ord(wires[bundle]['colors'][x][0]))+str(idcount)[-1] ident = ident.strip(" ") - notes = "none" + notes = "" + if str(connectors[connector]).count("'pinlabels':"): + stringarray = list(map(str,connectors[connector]['pinlabels'])) + if stringarray.count(connectorpinsadjusted[x][1:-1]): + pin1= connectors[connector]['pins'][stringarray.index(connectorpinsadjusted[x][1:-1])] if str(wires[bundle]).find("'notes':") > 0: notes = wires[bundle]['notes'] wire_info.append({ @@ -112,7 +118,7 @@ def parse_wireviz_yml(file_path): return wire_df # Path to your WireViz YML file -file_path = 'wireviz/Choppy_ECU_12FB.yml' +file_path = 'wireviz/Choppy_ECU_C1.yml' wire_table = parse_wireviz_yml(file_path) # Display the table |