[Qa-jenkins-scm] [jenkins.debian.net] 02/08: reproducible debian: move python 'gen_status_link_icon' function to common

Holger Levsen holger at layer-acht.org
Tue Jul 5 15:25:11 UTC 2016


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch master
in repository jenkins.debian.net.

commit 8c46f64b57464ba35d0c86d4a9f69c7e912396ab
Author: Valerie R Young <spectranaut at riseup.net>
Date:   Wed Jun 22 11:19:08 2016 -0400

    reproducible debian: move python 'gen_status_link_icon' function to common
    
    Signed-off-by: Mattia Rizzolo <mattia at debian.org>
    Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
 bin/reproducible_common.py              | 25 +++++++++++++++++++++++++
 bin/reproducible_html_packages.py       | 13 -------------
 bin/templates/status_icon_link.mustache |  2 ++
 3 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py
index cc69c95..7548a93 100755
--- a/bin/reproducible_common.py
+++ b/bin/reproducible_common.py
@@ -20,6 +20,7 @@ import atexit
 import sqlite3
 import logging
 import argparse
+import pystache
 import psycopg2
 import html as HTML
 from string import Template
@@ -138,6 +139,11 @@ if args.ignore_missing_files:
 
 tab = '  '
 
+# Templates used for creating package pages
+renderer = pystache.Renderer();
+status_icon_link_template = renderer.load_template(
+    TEMPLATE_PATH + '/status_icon_link')
+
 html_header = Template("""<!DOCTYPE html>
 <html>
   <head>
@@ -529,6 +535,25 @@ def get_status_icon(status):
         return (status, '', spokenstatus)
 
 
+def gen_status_link_icon(status, spokenstatus, icon, suite, arch):
+    """
+    Returns the html for "<icon> <spokenstatus>" with both icon and status
+    linked to the appropriate index page for the status, arch and suite.
+
+    If icon is set to None, the icon will be ommited.
+    If spokenstatus is set to None, the spokenstatus link be ommited.
+    """
+    context = {
+        'status': status,
+        'spokenstatus': spokenstatus,
+        'icon': icon,
+        'suite': suite,
+        'arch': arch,
+        'untested': True if status == 'untested' else False,
+    }
+    return renderer.render(status_icon_link_template, context)
+
+
 def strip_epoch(version):
     """
     Stip the epoch out of the version string. Some file (e.g. buildlogs, debs)
diff --git a/bin/reproducible_html_packages.py b/bin/reproducible_html_packages.py
index 8c1d871..3a234cc 100755
--- a/bin/reproducible_html_packages.py
+++ b/bin/reproducible_html_packages.py
@@ -22,8 +22,6 @@ suitearch_section_template = renderer.load_template(
     TEMPLATE_PATH + '/package_suitearch_section')
 suitearch_details_template = renderer.load_template(
     TEMPLATE_PATH + '/package_suitearch_details')
-status_icon_link_template = renderer.load_template(
-    TEMPLATE_PATH + '/status_icon_link')
 
 def sizeof_fmt(num):
     for unit in ['B','KB','MB','GB']:
@@ -36,17 +34,6 @@ def sizeof_fmt(num):
     return str(int(round(float("%f" % num), 0))) + "%s" % ('Yi')
 
 
-def gen_status_link_icon(status, spokenstatus, icon, suite, arch):
-    context = {
-        'status': status,
-        'spokenstatus': spokenstatus,
-        'icon': icon,
-        'suite': suite,
-        'arch': arch,
-        'untested': True if status == 'untested' else False,
-    }
-    return renderer.render(status_icon_link_template, context)
-
 def get_buildlog_links_context(package, eversion, suite, arch):
     log = suite + '/' + arch + '/' + package + '_' + eversion + '.build2.log.gz'
     diff = suite + '/' + arch + '/' + package + '_' + eversion + '.diff.gz'
diff --git a/bin/templates/status_icon_link.mustache b/bin/templates/status_icon_link.mustache
index 2b866f7..66bebfc 100644
--- a/bin/templates/status_icon_link.mustache
+++ b/bin/templates/status_icon_link.mustache
@@ -4,9 +4,11 @@
   <img src="/static/{{icon}}" alt="{{spokenstatus}}">
 </a>
 {{/icon}}
+{{#spokenstatus}}
 <a href="/debian/{{suite}}/{{arch}}/index_{{status}}.html" title="Go to: summary of all {{spokenstatus}} packages" target="_parent">
   {{spokenstatus}}
 </a>
+{{/spokenstatus}}
 {{/untested}}
 
 {{#untested}}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git



More information about the Qa-jenkins-scm mailing list