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")
self.assertEqual(len(text), 37)
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")
self.assertEqual(len(text), 84)
text = utils.css_tool.getExternalStyle("diffFiles")
@ -30,10 +36,21 @@ class MyTestCase(unittest.TestCase):
text = utils.css_tool.getInlineStyle("diffFiles", "diffA")
self.assertEqual(len(text), 13)
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")
print(text)
self.assertEqual(len(text), 237)
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")
self.assertEqual(len(text), 0)
print(text)
@ -51,6 +68,10 @@ class MyTestCase(unittest.TestCase):
self.assertEqual(len(text), 189)
print(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__':
unittest.main()

19
utils/css_tool.py

@ -8,6 +8,13 @@ CSS_CLASS = {
"diffB": "color:crimson;font-weight:bold;",
"acceptA": "color:darkblue;",
"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.replace(":", ": ").replace(";", "; ").replace("_Q_", ", ")
out += line
for c in CSS_CLASS[filetype]:
out += "\n."+c+" { "+CSS_CLASS[filetype][c].replace(":", ": ").replace(";", "; ")+"} "
arr = filetype.split(",")
for a in arr:
for c in CSS_CLASS[a]:
out += "\n."+c+" { "+CSS_CLASS[a][c].replace(":", ": ").replace(";", "; ")+"} "
out += "\n</style>"
elif job.conf.confs.get("tools").get("csstyp") == "external":
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
out = ""
if job.conf.confs.get("tools").get("csstyp") == "external":
for c in CSS_CLASS[filetype]:
out += c+" {\n "+CSS_CLASS[filetype][c].replace(":", ": ").replace(";", ";\n ")+"}\n"
arr = filetype.split(",")
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}")
return out

Loading…
Cancel
Save