[Reproducible-commits] [debbindiff] 02/05: Add support for an external CSS

Jérémy Bobbio lunar at moszumanska.debian.org
Sun Nov 9 11:41:39 UTC 2014


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

lunar pushed a commit to branch master
in repository debbindiff.

commit 7b6282d729ad975c57b09dade3d2bcc466614ddd
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Sun Nov 9 12:07:32 2014 +0100

    Add support for an external CSS
    
    Closes: #764470
---
 debbindiff.py                 |  4 +++-
 debbindiff/presenters/html.py | 15 +++++++++++++--
 debian/debbindiff.1.rst       |  3 ++-
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/debbindiff.py b/debbindiff.py
index 9fa4dd1..daaef02 100755
--- a/debbindiff.py
+++ b/debbindiff.py
@@ -38,6 +38,8 @@ def create_parser():
                         default=False, help='display debug messages')
     parser.add_argument('--html', metavar='output', dest='html_output',
                         help='write HTML report to given file')
+    parser.add_argument('--css', metavar='url', dest='css_url',
+                        help='link to an extra CSS for the HTML report')
     parser.add_argument('file1', help='first file to compare')
     parser.add_argument('file2', help='second file to compare')
     return parser
@@ -55,7 +57,7 @@ def main():
         def print_func(*args, **kwargs):
             kwargs['file'] = output
             print(*args, **kwargs)
-        output_html(differences, print_func=print_func)
+        output_html(differences, css_url=parsed_args.css_url, print_func=print_func)
     if len(differences) > 0:
         sys.exit(1)
 
diff --git a/debbindiff/presenters/html.py b/debbindiff/presenters/html.py
index 9bc1aa7..0cf0fea 100644
--- a/debbindiff/presenters/html.py
+++ b/debbindiff/presenters/html.py
@@ -76,6 +76,7 @@ HEADER = """
       font-weight: bold;
     }
   </style>
+  %(css_link)s
 </head>
 <body>
 """
@@ -166,12 +167,22 @@ def output_difference(difference, print_func):
         print_func("</div>", force=True)
 
 
-def output_html(differences, print_func=None):
+def output_header(css_url, print_func):
+    if css_url:
+        css_link = '<link href="%s" type="text/css" rel="stylesheet" />' % css_url
+    else:
+        css_link = ''
+    print_func(HEADER % {'title': escape(' '.join(sys.argv)),
+                         'css_link': css_link,
+                        })
+
+
+def output_html(differences, css_url=None, print_func=None):
     if print_func is None:
         print_func = print
     print_func = create_limited_print_func(print_func)
     try:
-        print_func(HEADER % {'title': escape(' '.join(sys.argv))})
+        output_header(css_url, print_func)
         for difference in differences:
             output_difference(difference, print_func)
     except PrintLimitReached:
diff --git a/debian/debbindiff.1.rst b/debian/debbindiff.1.rst
index 587a0fb..f5fd6ea 100644
--- a/debian/debbindiff.1.rst
+++ b/debian/debbindiff.1.rst
@@ -14,7 +14,7 @@ highlight differences between two builds of Debian packages
 SYNOPSIS
 ========
 
-  debbindiff [-h] [--version] [--debug] [--html output] file1 file2
+  debbindiff [-h] [--version] [--debug] [--html output] [--css url] file1 file2
 
 DESCRIPTION
 ===========
@@ -35,6 +35,7 @@ OPTIONS
 --version      show program's version number and exit
 --debug        display debug messages
 --html output  write HTML report to given file
+--css url      link to an extra CSS for the HTML report
 
 SEE ALSO
 ========

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/debbindiff.git



More information about the Reproducible-commits mailing list