[Reproducible-builds] Bug#778423: support a plain text output mode
Helmut Grohne
helmut at subdivi.de
Sat Feb 14 20:14:41 UTC 2015
Package: debbindiff
Version: 8
Severity: wishlist
Tags: patch
User: helmutg at debian.org
Usertags: rebootstrap
A limitation of rebootstrap currently is that it can only output a build
log. Thus I embed the debbindiffs into the log. This is cumbersome to
read, since they are unrendered html. Having a plain text output mode
would make reading these logs way easier. Not as easy as the html
rendered presentation, but still more useful.
I therefore ask to add a plain text output mode.
Oh and here is a patch. :)
Helmut
-------------- next part --------------
diff -Nru debbindiff-8/debbindiff/presenters/text.py debbindiff-8+nmu1/debbindiff/presenters/text.py
--- debbindiff-8/debbindiff/presenters/text.py 1970-01-01 00:00:00.000000000 +0000
+++ debbindiff-8+nmu1/debbindiff/presenters/text.py 2015-02-14 20:08:37.000000000 +0000
@@ -0,0 +1,17 @@
+import sys
+import difflib
+
+def output_text(differences):
+ for difference in differences:
+ print("difference between %s and %s" %
+ (difference.source1, difference.source2))
+ if difference.comment:
+ print("comment: %s" % difference.comment)
+ if difference.lines1 and difference.lines2:
+ for line in difflib.unified_diff(difference.lines1,
+ difference.lines2, difference.source1, difference.source2):
+ sys.stdout.write(line)
+ if difference.details:
+ print("descending into details")
+ output_text(difference.details)
+ print("returning from details")
diff -Nru debbindiff-8/debbindiff.py debbindiff-8+nmu1/debbindiff.py
--- debbindiff-8/debbindiff.py 2015-02-10 02:03:06.000000000 +0000
+++ debbindiff-8+nmu1/debbindiff.py 2015-02-14 20:03:12.000000000 +0000
@@ -26,6 +26,7 @@
from debbindiff import logger, VERSION
import debbindiff.comparators
from debbindiff.presenters.html import output_html
+from debbindiff.presenters.text import output_text
def create_parser():
@@ -38,6 +39,9 @@
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('--text', dest='text_output', default=False,
+ action='store_true',
+ help='write plain text output to stdout')
parser.add_argument('--max-report-size', metavar='BYTES',
dest='max_report_size', type=int,
help='maximum bytes written in report')
@@ -62,6 +66,8 @@
print(*args, **kwargs)
output_html(differences, css_url=parsed_args.css_url, print_func=print_func,
max_page_size=parsed_args.max_report_size)
+ if len(differences) > 0 and parsed_args.text_output:
+ output_text(differences)
if len(differences) > 0:
sys.exit(1)
diff -Nru debbindiff-8/debian/changelog debbindiff-8+nmu1/debian/changelog
--- debbindiff-8/debian/changelog 2015-02-10 02:03:06.000000000 +0000
+++ debbindiff-8+nmu1/debian/changelog 2015-02-14 20:10:12.000000000 +0000
@@ -1,3 +1,10 @@
+debbindiff (8+nmu1) UNRELEASED; urgency=medium
+
+ * Non-maintainer upload.
+ * Add a text presentation based on unified diffs. (Closes: #-1)
+
+ -- Helmut Grohne <helmut at subdivi.de> Sat, 14 Feb 2015 20:09:42 +0000
+
debbindiff (8) unstable; urgency=medium
[ Peter De Wachter ]
More information about the Reproducible-builds
mailing list