From 8a70a4216e22828e96266bf8892610c37a6750d7 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 17 Mar 2017 19:27:52 +0100 Subject: [PATCH] Adding roadmapProgressBar as a dirty subfolder --- roadmapProgressBar/analyze.py | 90 ++++++++++++++++ roadmapProgressBar/data/.gitkeep | 0 roadmapProgressBar/fetch.py | 14 +++ roadmapProgressBar/publish.py | 44 ++++++++ roadmapProgressBar/www/template.html | 154 +++++++++++++++++++++++++++ 5 files changed, 302 insertions(+) create mode 100755 roadmapProgressBar/analyze.py create mode 100644 roadmapProgressBar/data/.gitkeep create mode 100755 roadmapProgressBar/fetch.py create mode 100755 roadmapProgressBar/publish.py create mode 100644 roadmapProgressBar/www/template.html diff --git a/roadmapProgressBar/analyze.py b/roadmapProgressBar/analyze.py new file mode 100755 index 0000000..cabc823 --- /dev/null +++ b/roadmapProgressBar/analyze.py @@ -0,0 +1,90 @@ +#!/usr/bin/python3 + +import json +from bs4 import BeautifulSoup + + +status_filters = { + "all": None, + "new": ["New", "Confirmed"], + "ongoing": ["In Progress"], + "done": ["Closed", "Resolved", "Rejected"] + } + +type_filters = { + "all": None, + "Bug": "Bug", + "Feature": "Feature", + "Improve": "Improvement", + "Doc": "Documentation" + } + + + +def parse_issues(): + + soup = BeautifulSoup(open("data/raw_roadmapissues.xml").read(), "lxml") + + issues = [] + + for issue in soup.issues: + cleaned_issue = {} + cleaned_issue["id"] = issue.id.text + cleaned_issue["priority"] = issue.priority["name"] + cleaned_issue["status"] = issue.status["name"] + cleaned_issue["type"] = issue.tracker["name"] + + issues.append(cleaned_issue) + + return issues + + +def filtered_issues(issues, status_filter=None, type_filter=None): + + issues_filtered = issues + if status_filter != None: + issues_filtered = [ issue for issue in issues_filtered if issue["status"] in status_filter] + + if type_filter != None: + issues_filtered = [ issue for issue in issues_filtered if issue["type"] == type_filter ] + + return len(issues_filtered) + + +def main(): + + issues = parse_issues() + summary = {} + + for type_name, type_filter in type_filters.items(): + + summary[type_name] = {} + + for status_name, status_filter in status_filters.items(): + + summary[type_name][status_name] = filtered_issues(issues, status_filter, + type_filter) + + for type_name, type_filter in type_filters.items(): + + for status_name, status_filter in status_filters.items(): + + if (status_name != "all"): + + n = summary[type_name][status_name] + p = float("{0:.1f}".format(100 * n / summary[type_name]["all"])) + summary[type_name][status_name] = (n,p) + + if (type_name != "all"): + n = summary[type_name]["all"] + p = float("{0:.1f}".format(100 * n / summary["all"]["all"])) + summary[type_name]["all"] = (n,p) + + + + with open("summary.json", "w") as f: + f.write(json.dumps(summary)) + + +main() + diff --git a/roadmapProgressBar/data/.gitkeep b/roadmapProgressBar/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/roadmapProgressBar/fetch.py b/roadmapProgressBar/fetch.py new file mode 100755 index 0000000..af466e0 --- /dev/null +++ b/roadmapProgressBar/fetch.py @@ -0,0 +1,14 @@ +#!/usr/bin/python3 + +import requests +import json + +def get_roadmapissues(): + + roadmapissues = requests.get("https://dev.yunohost.org/issues.xml?fixed_version_id=11&status_id=*&limit=100") + + + with open("data/raw_roadmapissues.xml", "w") as f: + f.write(roadmapissues.text) + +get_roadmapissues() diff --git a/roadmapProgressBar/publish.py b/roadmapProgressBar/publish.py new file mode 100755 index 0000000..820ba03 --- /dev/null +++ b/roadmapProgressBar/publish.py @@ -0,0 +1,44 @@ +#!/usr/bin/python3 + +import os +import json + +from jinja2 import Template +from ansi2html import Ansi2HTMLConverter +from ansi2html.style import get_styles + +############################################################################### + +output_dir = "./www/" + +template_path = os.path.join(output_dir,"template.html") +output_path = os.path.join(output_dir,"index.html") + +summary_path = os.path.join("./", "summary.json") + +############################################################################### + +conv = Ansi2HTMLConverter() +shell_css = "\n".join(map(str, get_styles(conv.dark_bg, conv.scheme))) + +def shell_to_html(shell): + return conv.convert(shell, False) + +############################################################################### + +if __name__ == '__main__': + + # Fetch the list of all reports, sorted in reverse-chronological order + + summary = json.load(open(summary_path)) + + # Generate the output using the template + + template = open(template_path, "r").read() + t = Template(template) + + result = t.render(data=summary, convert=shell_to_html, shell_css=shell_css) + + open(output_path, "w").write(result) + + print("Done.") diff --git a/roadmapProgressBar/www/template.html b/roadmapProgressBar/www/template.html new file mode 100644 index 0000000..cc7fe0a --- /dev/null +++ b/roadmapProgressBar/www/template.html @@ -0,0 +1,154 @@ + + + + + + Yunohost Pull Requests Dashboard + + + + + + + + + + + + + +
+ + + +

2.6.x

+ +
+ +
+ +
All ({{data.all.all}} issues)
+
+
+
{{data.all.done[0]}} done
+
{{data.all.ongoing[0]}} + ongoing
+
{{data.all.new[0]}} new
+
+
+ + {% for type, statuses in data.items() %} + {% if type != "all" %} +
+
+
+ {{ statuses.done[0] }} +
+
+ {{ statuses.ongoing[0] }} +
+
+ {{ statuses.new[0] }} +
+
+
{{ type }}
({{ statuses.all[0] + }})
+
+ {% endif %} + {% endfor %} + +
+ +
+
+ +
+ + +
+
+
+
+

CSS Skin/boilerplate/whatever you call it : Script Eden.

+ +
+
+ +
+ + +
+ + + + + + + + +