Hardware number display fix

This commit is contained in:
Marianpol 2020-07-12 17:43:28 +02:00
parent 7c415e1665
commit 610699d2c4
3 changed files with 23 additions and 3 deletions

View File

@ -75,7 +75,7 @@ def find_DBs():
mod_globals.opt_ddt = True
#check cache version
verfilename = "./cache/version09r_fix#1.txt"
verfilename = "./cache/version09r_fix#2.txt"
if not os.path.isfile(verfilename):
#if the cache has old version then we should clear it
for root, dirs, files in os.walk("./cache"):

View File

@ -88,13 +88,33 @@ class ecu_identification:
for cmpt in Computation:
self.type = cmpt.getAttribute("type")
tmp = cmpt.getElementsByTagName("Value").item(0).firstChild.nodeValue
self.computation = tmp.replace(" ","").replace("&","&")
tmp = tmp.replace(" ","").replace("&","&")
questionMarkCount = tmp.count('?"')
if questionMarkCount:
tmp = self.changeHwNumberComputation(tmp, questionMarkCount)
self.computation = tmp
self.mnemolist = []
Mnemo = cmpt.getElementsByTagName("Mnemo")
if Mnemo:
for mn in Mnemo:
self.mnemolist.append(mn.getAttribute("name"))
def changeHwNumberComputation(self, comp, counter):
firstPos = 0
lastPos = 0
for num in range(counter):
firstPos = comp.find('?"', lastPos + 1)
if(comp[firstPos-1] != ')'):
mnemonicBegin = comp.rfind('(', lastPos ,firstPos)
mnemonicSubstring = comp[mnemonicBegin:firstPos]
if mnemonicSubstring.count('(') > 1:
return comp
comp = comp.replace(mnemonicSubstring, '('+ mnemonicSubstring + ')')
lastPos = firstPos + 2
return comp
class ecu_identifications:

View File

@ -197,7 +197,7 @@ class Calc(Parser):
def p_expression_plus(self, p):
'expression : expression PLUS expression'
if type(p[1]) is str or type(p[3]) is str:
p[0] = str(p[1]) + str(p[3])
p[0] = str(p[1]).replace('"', '') + str(p[3])
else:
p[0] = p[1] + p[3]
p_expression_plus.func_doc='expression : expression PLUS expression'