commit:     1d281c78d02de7a55fc918aa414d7e9620d8e101
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 17 16:59:49 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Dec 17 16:59:49 2017 +0000
URL:        https://gitweb.gentoo.org/proj/qa-scripts.git/commit/?id=1d281c78

pkgcheck2html: Group results by class

 htdocs/pkgcheck2html.css        |  8 ++++++++
 pkgcheck2html/output.html.jinja | 21 +++++++++++++++------
 pkgcheck2html/pkgcheck2html.py  | 14 +++++++++-----
 3 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/htdocs/pkgcheck2html.css b/htdocs/pkgcheck2html.css
index eb17b19..44862ce 100644
--- a/htdocs/pkgcheck2html.css
+++ b/htdocs/pkgcheck2html.css
@@ -171,6 +171,14 @@ tr.warn td:hover
        text-overflow: ellipsis;
 }
 
+li.heading
+{
+       font-size: 125%;
+       color: white;
+       background-color: #463C65;
+       padding-left: .75em;
+}
+
 .warn a
 {
        color: orange;

diff --git a/pkgcheck2html/output.html.jinja b/pkgcheck2html/output.html.jinja
index f8d6bf5..80c5167 100644
--- a/pkgcheck2html/output.html.jinja
+++ b/pkgcheck2html/output.html.jinja
@@ -14,14 +14,23 @@
                                <h2>issues</h2>
 
                                <ul>
-                                       {% for g in errors %}
-                                               <li class="err"><a href="#{{ 
g|join('/') }}">{{ g|join('/') }}</a></li>
+                                       {% for g, pkgs in errors %}
+                                               <li class="err heading">{{ g 
}}</li>
+                                               {% for pkg in pkgs %}
+                                                       <li class="err"><a 
href="#{{ g|join('/') }}">{{ g|join('/') }}</a></li>
+                                               {% endfor %}
                                        {% endfor %}
-                                       {% for g in warnings %}
-                                               <li class="warn"><a href="#{{ 
g|join('/') }}">{{ g|join('/') }}</a></li>
+                                       {% for g, pkgs in warnings %}
+                                               <li class="warn heading">{{ g 
}}</li>
+                                               {% for pkg in pkgs %}
+                                                       <li class="warn"><a 
href="#{{ g|join('/') }}">{{ g|join('/') }}</a></li>
+                                               {% endfor %}
                                        {% endfor %}
-                                       {% for g in staging %}
-                                               <li class="staging"><a 
href="#{{ g|join('/') }}">{{ g|join('/') }}</a></li>
+                                       {% for g, pkgs in staging %}
+                                               <li class="staging heading">{{ 
g }}</li>
+                                               {% for pkg in pkgs %}
+                                                       <li class="staging"><a 
href="#{{ pkg|join('/') }}">{{ pkg|join('/') }}</a></li>
+                                               {% endfor %}
                                        {% endfor %}
                                </ul>
                        </div>

diff --git a/pkgcheck2html/pkgcheck2html.py b/pkgcheck2html/pkgcheck2html.py
index da5dee5..ffdf76a 100755
--- a/pkgcheck2html/pkgcheck2html.py
+++ b/pkgcheck2html/pkgcheck2html.py
@@ -4,6 +4,7 @@
 # 2-clause BSD license
 
 import argparse
+import collections
 import datetime
 import io
 import json
@@ -77,11 +78,14 @@ def deep_group(it, level = 1):
 
 
 def find_of_class(it, cls, level = 2):
+    out = collections.defaultdict(set)
+
     for g, r in group_results(it, level):
         for x in r:
             if x.css_class == cls:
-                yield g
-                break
+                out[getattr(x, 'class')].add(g)
+
+    return [(k, sorted(v)) for k, v in sorted(out.items())]
 
 
 def get_result_timestamp(paths):
@@ -125,9 +129,9 @@ def main(*args):
 
     out = t.render(
         results = deep_group(results),
-        warnings = list(find_of_class(results, 'warn')),
-        staging = list(find_of_class(results, 'staging')),
-        errors = list(find_of_class(results, 'err')),
+        warnings = find_of_class(results, 'warn'),
+        staging = find_of_class(results, 'staging'),
+        errors = find_of_class(results, 'err'),
         ts = ts,
     )
 

Reply via email to