Browse Source

css for results

master
Ulrich Carmesin 3 years ago
parent
commit
271d4deece
  1. 21
      test/test_css.py
  2. 19
      utils/css_tool.py

21
test/test_css.py

@ -21,6 +21,12 @@ class MyTestCase(unittest.TestCase):
text = utils.css_tool.getInlineStyle("diffFiles", "diffA") text = utils.css_tool.getInlineStyle("diffFiles", "diffA")
self.assertEqual(len(text), 37) self.assertEqual(len(text), 37)
self.assertEqual(("style" in text), True) self.assertEqual(("style" in text), True)
text = utils.css_tool.getInlineStyle("diffFiles", "acceptA")
self.assertEqual(len(text), 23)
self.assertEqual(("style" in text), True)
text = utils.css_tool.getInlineStyle("resultFile", "result1")
self.assertEqual(len(text), 36)
self.assertEqual(("style" in text), True)
text = utils.css_tool.getInternalStyle("diffFiles") text = utils.css_tool.getInternalStyle("diffFiles")
self.assertEqual(len(text), 84) self.assertEqual(len(text), 84)
text = utils.css_tool.getExternalStyle("diffFiles") text = utils.css_tool.getExternalStyle("diffFiles")
@ -30,10 +36,21 @@ class MyTestCase(unittest.TestCase):
text = utils.css_tool.getInlineStyle("diffFiles", "diffA") text = utils.css_tool.getInlineStyle("diffFiles", "diffA")
self.assertEqual(len(text), 13) self.assertEqual(len(text), 13)
self.assertEqual(("class" in text), True) self.assertEqual(("class" in text), True)
text = utils.css_tool.getInlineStyle("resultFile", "result1")
self.assertEqual(len(text), 15)
self.assertEqual(("class" in text), True)
text = utils.css_tool.getInternalStyle("diffFiles") text = utils.css_tool.getInternalStyle("diffFiles")
print(text) print(text)
self.assertEqual(len(text), 237) self.assertEqual(len(text), 237)
self.assertEqual(("<style>" in text), True) self.assertEqual(("<style>" in text), True)
text = utils.css_tool.getInternalStyle("resultFile")
print(text)
self.assertEqual(len(text), 283)
self.assertEqual(("<style>" in text), True)
text = utils.css_tool.getInternalStyle("diffFiles,resultFile")
print(text)
self.assertEqual(len(text), 440)
self.assertEqual(("<style>" in text), True)
text = utils.css_tool.getExternalStyle("diffFiles") text = utils.css_tool.getExternalStyle("diffFiles")
self.assertEqual(len(text), 0) self.assertEqual(len(text), 0)
print(text) print(text)
@ -51,6 +68,10 @@ class MyTestCase(unittest.TestCase):
self.assertEqual(len(text), 189) self.assertEqual(len(text), 189)
print(text) print(text)
print(str(len(text))) print(str(len(text)))
text = utils.css_tool.getExternalStyle("diffFiles,resultFile")
self.assertEqual(len(text), 422)
print(text)
print(str(len(text)))
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

19
utils/css_tool.py

@ -8,6 +8,13 @@ CSS_CLASS = {
"diffB": "color:crimson;font-weight:bold;", "diffB": "color:crimson;font-weight:bold;",
"acceptA": "color:darkblue;", "acceptA": "color:darkblue;",
"acceptB": "color:darkmagenta;" "acceptB": "color:darkmagenta;"
},
"resultFile": {
"result0": "background-color:white;",
"result1": "background-color:lightgreen;",
"result2": "background-color:yellow;",
"result3": "background-color:tomato;",
"result4": "background-color:tomato;"
} }
} }
@ -31,8 +38,10 @@ def getInternalStyle(filetype):
line = "\n"+c+" { "+CSS_CLASS["general"][c]+"} " line = "\n"+c+" { "+CSS_CLASS["general"][c]+"} "
line.replace(":", ": ").replace(";", "; ").replace("_Q_", ", ") line.replace(":", ": ").replace(";", "; ").replace("_Q_", ", ")
out += line out += line
for c in CSS_CLASS[filetype]: arr = filetype.split(",")
out += "\n."+c+" { "+CSS_CLASS[filetype][c].replace(":", ": ").replace(";", "; ")+"} " for a in arr:
for c in CSS_CLASS[a]:
out += "\n."+c+" { "+CSS_CLASS[a][c].replace(":", ": ").replace(";", "; ")+"} "
out += "\n</style>" out += "\n</style>"
elif job.conf.confs.get("tools").get("csstyp") == "external": elif job.conf.confs.get("tools").get("csstyp") == "external":
out = " <link rel=\"stylesheet\" href=\""+job.conf.confs.get("tools").get("cssfile")+"\"> " out = " <link rel=\"stylesheet\" href=\""+job.conf.confs.get("tools").get("cssfile")+"\"> "
@ -50,7 +59,9 @@ def getExternalStyle(filetype):
verify = int(job.getDebugLevel("match_tool")) - 1 verify = int(job.getDebugLevel("match_tool")) - 1
out = "" out = ""
if job.conf.confs.get("tools").get("csstyp") == "external": if job.conf.confs.get("tools").get("csstyp") == "external":
for c in CSS_CLASS[filetype]: arr = filetype.split(",")
out += c+" {\n "+CSS_CLASS[filetype][c].replace(":", ": ").replace(";", ";\n ")+"}\n" for a in arr:
for c in CSS_CLASS[a]:
out += c+" {\n "+CSS_CLASS[a][c].replace(":", ": ").replace(";", ";\n ")+"}\n"
out.replace("\n \n}", "\n}") out.replace("\n \n}", "\n}")
return out return out

Loading…
Cancel
Save