From 91bacda06f3c535f5fbd79ea0bc1a226c93b1b5f Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Wed, 11 May 2016 04:11:21 +0200 Subject: reproducible debian: Have index_issues also show total popcon scores of each issue We add extra columns in the table, that indicate: 1. the total popcon of each issue's packages 2. the total sqrt-popcon of that 3. the count of that, as before We also change the default sort order to be (1) instead of (3) as before. Signed-off-by: Holger Levsen --- bin/reproducible_html_notes.py | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'bin/reproducible_html_notes.py') diff --git a/bin/reproducible_html_notes.py b/bin/reproducible_html_notes.py index 15f6068a..a0e8a030 100755 --- a/bin/reproducible_html_notes.py +++ b/bin/reproducible_html_notes.py @@ -11,7 +11,9 @@ # Build html pages based on the content of the notes.git repository import copy +import popcon import yaml +from math import sqrt from reproducible_common import * from reproducible_html_packages import gen_packages_html from reproducible_html_indexes import build_page @@ -224,10 +226,7 @@ def gen_html_note(package, note): tmp = '' for issue in note['issues']: tmp += fill_issue_in_note(issue) - try: - issues_count[issue].append(note['package']) - except KeyError: - issues_count[issue] = [note['package']] + issues_count.setdefault(issue, []).append(note['package']) infos += note_issues_html.substitute(issues=tmp) # check for bugs: if 'bugs' in note: @@ -387,27 +386,30 @@ def iterate_over_issues(issues): log.info('Created ' + str(i) + ' issue pages for ' + suite) -def sort_issues(issue): +def sort_issues(scorefunc, issue): try: - return (-len(issues_count[issue]), issue) + return (-scorefunc(issues_count[issue]), issue) except KeyError: # there are no packages affected by this issue return (0, issue) -def index_issues(issues): +def index_issues(issues, scorefuncs): + firstscorefunc = next(iter(scorefuncs.values())) templ = "\n\n" + tab + "\n" + tab*2 + "\n" + tab*2 + "\n" + tab*2 + "\n" + tab + "\n" html = (tab*2).join(templ.splitlines(True)) - for issue in sorted(issues, key=sort_issues): + for issue in sorted(issues, key=lambda issue: sort_issues(firstscorefunc, issue)): html += tab*3 + '\n' html += tab*4 + '\n' + issues_list = issues_count.get(issue, []) + for scorefunc in scorefuncs.values(): + html += tab*4 + '\n' html += tab*4 + '\n' html += tab*3 + '\n' html += tab*2 + '
\n" \ + tab*3 + "Identified issues\n" + tab*2 + "\n" \ + + "".join( + tab*3 + k + "\n" + tab*2 + "\n" + for k in scorefuncs.keys()) \ + tab*3 + "Affected packages\n" + tab*2 + "
' + issue + '' + str(scorefunc(issues_list)) + '\n' - try: - html += tab*5 + '' + str(len(issues_count[issue])) + ':\n' - html += tab*5 + ', '.join(issues_count[issue]) + '\n' - except KeyError: # there are no packages affected by this issue - html += tab*5 + '0\n' + html += tab*5 + ', '.join(issues_list) + '\n' html += tab*4 + '
\n' @@ -433,7 +435,11 @@ if __name__ == '__main__': issues = load_issues() iterate_over_notes(notes) iterate_over_issues(issues) - index_issues(issues) + index_issues(issues, { + 'Total popcon score': lambda l: sum(popcon.package(*l).values()), + 'Total of sqrt(popcon score)': lambda l: sum(map(sqrt, popcon.package(*l).values())), + 'Total number': len, + }) purge_old_notes(notes) purge_old_issues(issues) gen_packages_html([Package(x) for x in notes]) -- cgit v1.2.3-54-g00ecf