[Reportbug-commits] [SCM] Reportbug - reports bugs in the Debian distribution branch, master, updated. 4.9-83-g84fd47c

Sandro Tosi morph at debian.org
Fri Apr 2 07:17:48 UTC 2010


The following commit has been merged in the master branch:
commit 84fd47c6a86e003e4720c9d92b00b87fd9396a30
Author: Sandro Tosi <morph at debian.org>
Date:   Thu Apr 1 23:58:16 2010 +0200

    new method to correctly wrap the report body: before the text was all on a single line, now the long lines are wrapped but the paragraph formatting is preserved; thanks to Witold Baryluk for the report; Closes: #576116

diff --git a/debian/changelog b/debian/changelog
index bcd6e7f..2649307 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -17,6 +17,9 @@ reportbug (4.12) UNRELEASED; urgency=low
     - pass 'buglist' to 'sync_pre_operation' method of 'HandleBTSQueryPage'
       class, needed to run querybts; thanks to Andrey Rahmatullin for the
       report; Closes: #565283
+    - new method to correctly wrap the report body: before the text was all on a
+      single line, now the long lines are wrapped but the paragraph formatting
+      is preserved; thanks to Witold Baryluk for the report; Closes: #576116
   * bin/*, reportbub/*
     - add a user-configurable network timeout, adding the CLI option --timeout;
       thanks to Miles Bader for the report; Closes: #572316
@@ -25,7 +28,7 @@ reportbug (4.12) UNRELEASED; urgency=low
       network error might be due to a too low timeout; thanks to Michal Suchanek
       for the report; Closes: #571955
 
- -- Sandro Tosi <morph at debian.org>  Tue, 30 Mar 2010 21:49:15 +0200
+ -- Sandro Tosi <morph at debian.org>  Thu, 01 Apr 2010 23:56:02 +0200
 
 reportbug (4.11) unstable; urgency=low
 
diff --git a/reportbug/ui/gtk2_ui.py b/reportbug/ui/gtk2_ui.py
index 50ec332..b85a4b2 100644
--- a/reportbug/ui/gtk2_ui.py
+++ b/reportbug/ui/gtk2_ui.py
@@ -307,13 +307,33 @@ class BugReport (object):
                 self.headers[i] = 'Subject: '+subject
                 break
 
+    def wrap_bug_body (self, msg, width=79, break_long_words=False):
+        """Wrap every line in the message"""
+
+        # resulting body text
+        body = ''
+        for line in msg.splitlines():
+            # wrap long lines, it returns a list of "sub-lines"
+            tmp = textwrap.wrap(line, width=width,
+                                break_long_words=break_long_words)
+            # need to special-case this else a join() on the list generator
+            # would remove all the '[]' so no empty lines in the report
+            if tmp == []:
+                body += '\n'
+            else:
+                # join the "sub-lines" and add a \n at the end (if there is
+                # only one item in the list, else there wouldn't be a \n)
+                body += '\n'.join(tmp) + '\n'
+
+        return body
+
     def create_message (self, info):
         message = """%s
 
 %s
 
 
-%s""" % ('\n'.join (self.headers), textwrap.fill (info, width=79), self.others)
+%s""" % ('\n'.join (self.headers), self.wrap_bug_body (info), self.others)
         return message
 
 # BTS GUI

-- 
Reportbug - reports bugs in the Debian distribution



More information about the Reportbug-commits mailing list