summaryrefslogtreecommitdiff
path: root/scripts/html_task.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/html_task.py')
-rwxr-xr-xscripts/html_task.py194
1 files changed, 194 insertions, 0 deletions
diff --git a/scripts/html_task.py b/scripts/html_task.py
new file mode 100755
index 0000000..596b43b
--- /dev/null
+++ b/scripts/html_task.py
@@ -0,0 +1,194 @@
+#! /usr/bin/env python3
+#===============================
+#
+# html_task
+#
+# 2021/02/09 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+#===============================
+import sys
+import os
+import re
+
+import view
+import html_base
+from html_base import html
+#====================================
+#
+# periject_html
+#
+#====================================
+class periject_html(html_base.myhtml):
+
+ def __init__(self):
+ super().__init__()
+
+ #--------------------
+ # task_commit_bsp
+ #--------------------
+ def task_commit_bsp(self, v):
+ cnt = 0
+ with html("table"):
+ for b in self.bsp_list():
+ bsp_list = v.get_data(b)
+ if (not bsp_list):
+ continue
+ with html("tr"):
+ html("th").print(b)
+ with html("td"):
+ cnt += self.print_commit_bsp(bsp_list)
+ return cnt
+
+ #--------------------
+ # task_status
+ #--------------------
+ def task_status(self, v):
+ dir = os.path.dirname(v.file)
+ assignee = v.get_data("assignee")
+ status = v.get_data("status")
+ team = v.get_data("team")
+
+ if (not len(assignee)):
+ assignee = "NoAssignee"
+
+ with html("table", {"border":"1"}):
+ with html("tr"):
+ html("th").print("file")
+ html("th").print("status")
+ html("th").print("team")
+ html("th").print("assignee")
+ html("th").print("key")
+
+ with html("tr"):
+ html("td").print(os.path.relpath(v.file, self.top()))
+ html("td").print(html("a", {"target":"summary",
+ "href":self.relpath("html/{}.html".format(status), dir)}).text(status))
+ html("td").print(html("a", {"target":"summary",
+ "href":self.relpath("html/{}.html".format(team), dir)}).text(team))
+ html("td").print(html("a", {"target":"summary",
+ "href":self.relpath("html/{}.html".format(assignee), dir)}).text(assignee))
+ html("td").print(v.get_data("key"))
+
+ #--------------------
+ # _task_relation
+ #--------------------
+ def _task_relation(self, relationship, v, item):
+
+ current_dir = os.path.dirname(v.file)
+ related_file = v.get_related_file(relationship[item])
+
+ if (not os.path.exists(related_file)):
+ with html("tr"):
+ html("td").print(item)
+ html("td").print("Unknown({})".format(related_file))
+ return
+
+ rv = view.viewer([related_file])
+ rv.set_data(related_file)
+ with html("tr"):
+ html("td").print(item)
+ html("td").print(html("a", {"href":
+ self.relpath_y2h(related_file, current_dir)}).text(rv.get_data("title")))
+
+ #--------------------
+ # task_relation
+ #--------------------
+ def task_relation(self, v):
+
+ relationships = v.get_data("relationships")
+ if (not relationships):
+ return
+
+ current_dir = os.path.dirname(v.file)
+
+ with html("table", {"border":"1"}):
+ for relationship in relationships:
+ if ("parent" in relationship):
+ self._task_relation(relationship, v, "parent")
+ if ("depends" in relationship):
+ self._task_relation(relationship, v, "depends")
+ if ("blocks" in relationship):
+ self._task_relation(relationship, v, "blocks")
+
+ #--------------------
+ # task_head
+ #--------------------
+ def task_head(self, v):
+
+ with html("table"):
+ with html("tr"):
+ with html("td"):
+ self.task_status(v)
+ with html("td"):
+ self.task_relation(v)
+
+ #--------------------
+ # task_commit
+ #--------------------
+ def task_commit(self, v):
+
+ has_bsp = 0
+ for b in self.bsp_list():
+ if (v.get_data(b)):
+ has_bsp = 1
+ break
+ upstream = v.get_data("upstream")
+
+ with html("table", {"border":"1"}):
+ with html("tr"):
+ if (has_bsp):
+ html("th").print("BSP")
+ if (upstream):
+ html("th").print("upstream")
+ with html("tr"):
+ if (has_bsp):
+ with html("td"):
+ self.task_commit_bsp(v)
+ if (upstream):
+ with html("td"):
+ self.task_commit_upstream(v)
+
+ #--------------------
+ # task_comment
+ #--------------------
+ def task_comment(self, v):
+ comments = v.get_data("comments")
+ if (not comments):
+ return
+
+ with html("ul"):
+ for comment in comments:
+ str = re.search(r'(https?://[\w/:%#\$&\?\(\)~\.=\+\-]+)', comment)
+ if (str):
+ a = html("a", {"href":str.group(),
+ "target":"_blank"})
+ comment = str.string[:str.start()] + a.text(str.group()) + str.string[str.end():]
+
+ html("li").print(comment)
+
+ #--------------------
+ # print
+ #--------------------
+ def print(self, argv):
+ # remove this script
+ argv.pop(0)
+
+ v = view.viewer([argv[0]])
+ v.set_data(argv[0])
+
+ dir = os.path.dirname(argv[0].replace("projects", "html"))
+
+ self.print_css(dir)
+ with html("body"):
+ html("h2").print(v.get_data("title"))
+ self.task_head(v)
+ self.task_commit(v)
+ self.task_comment(v)
+
+#====================================
+#
+# As command
+#
+#====================================
+if __name__=='__main__':
+ # html_task.py projects/xxx/xxx.yaml
+ periject_html().print(sys.argv)