|
@ -94,6 +94,8 @@ class Matching(): |
|
|
self.matchkeys = {} |
|
|
self.matchkeys = {} |
|
|
|
|
|
|
|
|
def isHitA(self, key): |
|
|
def isHitA(self, key): |
|
|
|
|
|
print("isHitA "+str(key)) |
|
|
|
|
|
for k in self.linksA: print(k) |
|
|
return ((key in self.linksA) and (self.linksA[key] != "null")) |
|
|
return ((key in self.linksA) and (self.linksA[key] != "null")) |
|
|
def isHitB(self, key): |
|
|
def isHitB(self, key): |
|
|
return ((key in self.linksB) and (self.linksB[key] != "null")) |
|
|
return ((key in self.linksB) and (self.linksB[key] != "null")) |
|
@ -120,7 +122,7 @@ class Matching(): |
|
|
return ddl |
|
|
return ddl |
|
|
def setDiffHeader(matching): |
|
|
def setDiffHeader(matching): |
|
|
job = basic.program.Job.getInstance() |
|
|
job = basic.program.Job.getInstance() |
|
|
verify = int(job.getDebugLevel("match_tool"))-4 |
|
|
verify = int(job.getDebugLevel("match_tool"))-1 |
|
|
job.debug(verify, "getDiffHeader ") |
|
|
job.debug(verify, "getDiffHeader ") |
|
|
htmltxt = "<!DOCTYPE html>" |
|
|
htmltxt = "<!DOCTYPE html>" |
|
|
htmltxt += "<html><head>" |
|
|
htmltxt += "<html><head>" |
|
@ -159,17 +161,21 @@ def matchBestfit(matching, path): |
|
|
:return: |
|
|
:return: |
|
|
""" |
|
|
""" |
|
|
i=0 |
|
|
i=0 |
|
|
for r in matching.sideA: |
|
|
if (matching.sideA is not None): |
|
|
k = composeKey("a", i) |
|
|
for r in matching.sideA: |
|
|
matching.setHit(k, "null") |
|
|
k = composeKey("a", i) |
|
|
i += 1 |
|
|
matching.setHit(k, "null") |
|
|
|
|
|
i += 1 |
|
|
i = 0 |
|
|
i = 0 |
|
|
for r in matching.sideB: |
|
|
if (matching.sideB is not None): |
|
|
k = composeKey("b", i) |
|
|
for r in matching.sideB: |
|
|
matching.setHit("null", k) |
|
|
k = composeKey("b", i) |
|
|
i += 1 |
|
|
matching.setHit("null", k) |
|
|
|
|
|
i += 1 |
|
|
ia = 0 |
|
|
ia = 0 |
|
|
ix = 1 |
|
|
ix = 1 |
|
|
|
|
|
if (matching.sideA is None) or (matching.sideB is None): |
|
|
|
|
|
return |
|
|
for rA in matching.sideA: |
|
|
for rA in matching.sideA: |
|
|
ib = 0 |
|
|
ib = 0 |
|
|
for rB in matching.sideB: |
|
|
for rB in matching.sideB: |
|
@ -253,7 +259,6 @@ def getSimilarity(matching, path, rA, rB, i): |
|
|
|
|
|
|
|
|
def matchTree(matching): |
|
|
def matchTree(matching): |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
:param matching: |
|
|
:param matching: |
|
|
:return: |
|
|
:return: |
|
|
""" |
|
|
""" |
|
@ -293,8 +298,6 @@ def getEvaluation(matching, type, acceptance, sideA, sideB): |
|
|
verify = int(job.getDebugLevel("match_tool"))-1 |
|
|
verify = int(job.getDebugLevel("match_tool"))-1 |
|
|
job.debug(verify, "getEvaluation "+str(sideA)+" ?= "+str(sideB)) |
|
|
job.debug(verify, "getEvaluation "+str(sideA)+" ?= "+str(sideB)) |
|
|
match = getStringSimilarity(str(sideA), str(sideB)) |
|
|
match = getStringSimilarity(str(sideA), str(sideB)) |
|
|
colorA = "black" |
|
|
|
|
|
colorB = "black" |
|
|
|
|
|
classA = "black" |
|
|
classA = "black" |
|
|
classB = "black" |
|
|
classB = "black" |
|
|
result = "test" |
|
|
result = "test" |
|
@ -302,41 +305,39 @@ def getEvaluation(matching, type, acceptance, sideA, sideB): |
|
|
if acceptance == "ignore": result = "ignore" |
|
|
if acceptance == "ignore": result = "ignore" |
|
|
if (matching.matchtype == MATCH_POSTCOND) and (result == "test"): |
|
|
if (matching.matchtype == MATCH_POSTCOND) and (result == "test"): |
|
|
result = "hard" |
|
|
result = "hard" |
|
|
colorA = "green" |
|
|
|
|
|
colorB = "crimson" |
|
|
|
|
|
classA = "diffA" |
|
|
classA = "diffA" |
|
|
classB = "diffB" |
|
|
classB = "diffB" |
|
|
else: |
|
|
else: |
|
|
colorA = "darkblue" |
|
|
|
|
|
colorB = "darkmagenta" |
|
|
|
|
|
classA = "acceptA" |
|
|
classA = "acceptA" |
|
|
classB = "acceptB" |
|
|
classB = "acceptB" |
|
|
return [result, colorA, colorB, classA, classB] |
|
|
return [result, classA, classB] |
|
|
|
|
|
|
|
|
def matchDict(matching, A, B, path): |
|
|
def matchDict(matching, A, B, path): |
|
|
""" travers through the datatree """ |
|
|
""" travers through the datatree """ |
|
|
job = basic.program.Job.getInstance() |
|
|
job = basic.program.Job.getInstance() |
|
|
verify = int(job.getDebugLevel("match_tool"))-4 |
|
|
verify = int(job.getDebugLevel("match_tool"))-4 |
|
|
job.debug(verify, "matchDict "+path) |
|
|
job.debug(verify, "matchDict "+path) |
|
|
for k in A: |
|
|
if (A is not None): |
|
|
print(k) |
|
|
for k in A: |
|
|
if k == "_match": |
|
|
print(k) |
|
|
continue |
|
|
if k == "_match": |
|
|
if (B is not None) and (B[k]): |
|
|
continue |
|
|
if (isinstance(A[k], dict)): A[k]["_match"] = "Y" |
|
|
if (B is not None) and (B[k]): |
|
|
if (isinstance(B[k], dict)): B[k]["_match"] = "Y" |
|
|
if (isinstance(A[k], dict)): A[k]["_match"] = "Y" |
|
|
matchElement(matching, A[k], B[k], path+":"+k) |
|
|
if (isinstance(B[k], dict)): B[k]["_match"] = "Y" |
|
|
else: |
|
|
matchElement(matching, A[k], B[k], path+":"+k) |
|
|
if (isinstance(A[k], dict)): A[k]["_march"] = "N" |
|
|
else: |
|
|
matchElement(matching, A[k], None, path+":"+k) |
|
|
if (isinstance(A[k], dict)): A[k]["_march"] = "N" |
|
|
for k in B: |
|
|
matchElement(matching, A[k], None, path+":"+k) |
|
|
if k == "_match": |
|
|
if (B is not None): |
|
|
continue |
|
|
for k in B: |
|
|
if (A is not None) and (A[k]): |
|
|
if k == "_match": |
|
|
continue |
|
|
continue |
|
|
else: |
|
|
if (A is not None) and (A[k]): |
|
|
if (isinstance(A[k], dict)): B[k]["_match"] = "N" |
|
|
continue |
|
|
matchElement(matching, None, B[k], path+":"+k) |
|
|
else: |
|
|
|
|
|
if (A is not None) and (isinstance(A[k], dict)): B[k]["_match"] = "N" |
|
|
|
|
|
matchElement(matching, None, B[k], path+":"+k) |
|
|
return matching |
|
|
return matching |
|
|
|
|
|
|
|
|
def matchArray(matching, A, B, path): |
|
|
def matchArray(matching, A, B, path): |
|
@ -370,12 +371,39 @@ def compareRows(matching, path): |
|
|
header.append({ "field": f, "type": ddl[f]["type"], "acceptance": ddl[f]["acceptance"]}) |
|
|
header.append({ "field": f, "type": ddl[f]["type"], "acceptance": ddl[f]["acceptance"]}) |
|
|
htmltext += "<th>"+f+"</th>" |
|
|
htmltext += "<th>"+f+"</th>" |
|
|
htmltext += "</tr>" |
|
|
htmltext += "</tr>" |
|
|
|
|
|
matching.difftext = htmltext |
|
|
for k in sorted(matching.linksA): |
|
|
for k in sorted(matching.linksA): |
|
|
htmltext += compareRow(matching, header, matching.sideA[int(extractKeyI(k))], |
|
|
print(k) |
|
|
|
|
|
if (matching.isHitA(k)): |
|
|
|
|
|
htmltext += compareRow(matching, header, matching.sideA[int(extractKeyI(k))], |
|
|
matching.sideB[int(extractKeyI(matching.linksA[k]))]) |
|
|
matching.sideB[int(extractKeyI(matching.linksA[k]))]) |
|
|
|
|
|
else: |
|
|
|
|
|
htmltext += markRow(matching, header, matching.sideA[int(extractKeyI(k))], "A") |
|
|
|
|
|
for k in sorted(matching.linksB): |
|
|
|
|
|
if (not matching.isHitB(k)): |
|
|
|
|
|
htmltext += markRow(matching, header, matching.sideB[int(extractKeyI(k))], "B") |
|
|
htmltext += "</table>" |
|
|
htmltext += "</table>" |
|
|
|
|
|
matching.difftext += "</table>" |
|
|
return htmltext |
|
|
return htmltext |
|
|
|
|
|
|
|
|
|
|
|
def markRow(matching, header, row, side): |
|
|
|
|
|
job = basic.program.Job.getInstance() |
|
|
|
|
|
verify = int(job.getDebugLevel("match_tool"))-4 |
|
|
|
|
|
text = "" |
|
|
|
|
|
cssClass = "" |
|
|
|
|
|
for f in header: |
|
|
|
|
|
if side == "A": |
|
|
|
|
|
res = getEvaluation(matching, f["type"], f["acceptance"], row[f["field"]], "") |
|
|
|
|
|
cssClass = res[1] |
|
|
|
|
|
else: |
|
|
|
|
|
res = getEvaluation(matching, f["type"], f["acceptance"], "", row[f["field"]]) |
|
|
|
|
|
cssClass = res[2] |
|
|
|
|
|
text += "<td "+utils.css_tool.getInlineStyle("diffFiles", cssClass)+">" + str(row[f["field"]]) + "</td>" |
|
|
|
|
|
text = "<tr><td "+utils.css_tool.getInlineStyle("diffFiles", cssClass)+">" \ |
|
|
|
|
|
+ MATCH[matching.matchtype]["short"+side] + "</td>" + text + "</tr>" |
|
|
|
|
|
matching.difftext += text |
|
|
|
|
|
return text |
|
|
|
|
|
|
|
|
def compareRow(matching, header, rA, rB): |
|
|
def compareRow(matching, header, rA, rB): |
|
|
""" traverse through matched rows """ |
|
|
""" traverse through matched rows """ |
|
|
job = basic.program.Job.getInstance() |
|
|
job = basic.program.Job.getInstance() |
|
@ -383,14 +411,13 @@ def compareRow(matching, header, rA, rB): |
|
|
allident = True |
|
|
allident = True |
|
|
textA = "" |
|
|
textA = "" |
|
|
textB = "" |
|
|
textB = "" |
|
|
|
|
|
text = "" |
|
|
for f in header: |
|
|
for f in header: |
|
|
print(f) |
|
|
print(f) |
|
|
res = getEvaluation(matching, f["type"], f["acceptance"], rA[f["field"]], rB[f["field"]]) |
|
|
res = getEvaluation(matching, f["type"], f["acceptance"], rA[f["field"]], rB[f["field"]]) |
|
|
match = res[0] |
|
|
match = res[0] |
|
|
colorA = res[1] |
|
|
classA = res[1] |
|
|
colorB = res[2] |
|
|
classB = res[2] |
|
|
classA = res[3] |
|
|
|
|
|
classB = res[4] |
|
|
|
|
|
if (match == "MATCH"): |
|
|
if (match == "MATCH"): |
|
|
textA += "<td>"+str(rA[f["field"]])+"</td>" |
|
|
textA += "<td>"+str(rA[f["field"]])+"</td>" |
|
|
textB += "<td>"+str(rB[f["field"]])+"</td>" |
|
|
textB += "<td>"+str(rB[f["field"]])+"</td>" |
|
@ -398,28 +425,17 @@ def compareRow(matching, header, rA, rB): |
|
|
allident = False |
|
|
allident = False |
|
|
textA += "<td "+utils.css_tool.getInlineStyle("diffFiles", classA)+">" + str(rA[f["field"]]) + "</td>" |
|
|
textA += "<td "+utils.css_tool.getInlineStyle("diffFiles", classA)+">" + str(rA[f["field"]]) + "</td>" |
|
|
textB += "<td "+utils.css_tool.getInlineStyle("diffFiles", classB)+">" + str(rB[f["field"]]) + "</td>" |
|
|
textB += "<td "+utils.css_tool.getInlineStyle("diffFiles", classB)+">" + str(rB[f["field"]]) + "</td>" |
|
|
#textB += "<td style=\"color:" + colorB + ";\">" + str(rB[f["field"]]) + "</td>" |
|
|
|
|
|
else: |
|
|
else: |
|
|
allident = False |
|
|
allident = False |
|
|
textA += "<td "+utils.css_tool.getInlineStyle("diffFiles", classA)+">"+str(rA[f["field"]])+" ("+match+")</td>" |
|
|
textA += "<td "+utils.css_tool.getInlineStyle("diffFiles", classA)+">"+str(rA[f["field"]])+" ("+match+")</td>" |
|
|
textB += "<td "+utils.css_tool.getInlineStyle("diffFiles", classB)+">"+str(rB[f["field"]])+" ("+match+")</td>" |
|
|
textB += "<td "+utils.css_tool.getInlineStyle("diffFiles", classB)+">"+str(rB[f["field"]])+" ("+match+")</td>" |
|
|
#textB += "<td style=\"color:"+colorB+";\">"+str(rA[f["field"]])+" ("+match+")</td>" |
|
|
|
|
|
if allident: |
|
|
if allident: |
|
|
return "<tr><td/>"+textA+"</tr>" |
|
|
return "<tr><td/>"+textA+"</tr>" |
|
|
return "<tr><td>"+MATCH[matching.matchtype]["shortA"]+"</td>"+textA+"</tr><tr><td>"+MATCH[matching.matchtype]["shortB"]+"</td>"+textB+"</tr>" |
|
|
text = "<tr><td>"+MATCH[matching.matchtype]["shortA"]+"</td>"+textA+"</tr><tr><td>"+MATCH[matching.matchtype]["shortB"]+"</td>"+textB+"</tr>" |
|
|
|
|
|
matching.difftext += text |
|
|
|
|
|
return text |
|
|
|
|
|
|
|
|
# -------------------------------------------------------------------------- |
|
|
# -------------------------------------------------------------------------- |
|
|
def matchLines(matching): |
|
|
def matchLines(matching): |
|
|
pass |
|
|
pass |
|
|
|
|
|
|
|
|
# -------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
|
|
def getScoreint(score): |
|
|
|
|
|
if score.is_integer(): |
|
|
|
|
|
return score |
|
|
|
|
|
elif "h_" in score: |
|
|
|
|
|
return int(score[2:]) |
|
|
|
|
|
def getHitscore(score): |
|
|
|
|
|
return "h_" + ':04d'.format(getScoreint(score)) |
|
|
|
|
|
def getNextHitscore(score): |
|
|
|
|
|
return "h_" + ':04d'.format(getScoreint(score)+1) |
|
|
|
|
|