[diffoscope] 04/04: presenters.text: Apply --max-report-size to --text reports. (Closes: #851147)

Chris Lamb chris at chris-lamb.co.uk
Tue Feb 7 11:10:15 CET 2017


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

lamby pushed a commit to branch master
in repository diffoscope.

commit 7479e160411b62fa12206a2443939fed2202b397
Author: Chris Lamb <lamby at debian.org>
Date:   Tue Feb 7 23:09:44 2017 +1300

    presenters.text: Apply --max-report-size to --text reports. (Closes: #851147)
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 diffoscope/presenters/text.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/diffoscope/presenters/text.py b/diffoscope/presenters/text.py
index b1cb753..ab54d19 100644
--- a/diffoscope/presenters/text.py
+++ b/diffoscope/presenters/text.py
@@ -20,8 +20,9 @@
 import re
 
 from diffoscope.diff import color_unified_diff
+from diffoscope.config import Config
 
-from .utils import Presenter
+from .utils import Presenter, create_limited_print_func, PrintLimitReached
 
 
 class TextPresenter(Presenter):
@@ -29,11 +30,20 @@ class TextPresenter(Presenter):
     RE_PREFIX = re.compile(r'(^|\n)')
 
     def __init__(self, print_func, color):
-        self.print_func = print_func
+        self.print_func = create_limited_print_func(
+            print_func,
+            Config().max_report_size,
+        )
         self.color = color
 
         super().__init__()
 
+    def start(self, difference):
+        try:
+            super().start(difference)
+        except PrintLimitReached:
+            self.print_func("Max output size reached.", force=True)
+
     def visit_difference(self, difference):
         if self.depth == 0:
             self.output("--- {}".format(difference.source1))

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


More information about the diffoscope mailing list