Re: patch for whitespace in help output

David Goodger <[email protected]> Tue, 26 Aug 2003 22:05:52 -0400
Newsgroups gmane.comp.python.optik.user
Message-ID <[email protected]>
The option_parser.OptionContainer.format_help patch has grown.
Handling of descriptions in option groups requires a bit more
complexity:

Index: lib/option_parser.py
===================================================================
RCS file: /cvsroot/optik/optik/lib/option_parser.py,v
retrieving revision 1.56
diff -u -r1.56 option_parser.py
--- lib/option_parser.py	15 Jul 2003 00:01:59 -0000	1.56
+++ lib/option_parser.py	27 Aug 2003 01:54:06 -0000
@@ -255,11 +255,12 @@
              return ""

      def format_help (self, formatter):
+        result = []
          if self.description:
-            desc = self.format_description(formatter) + "\n"
-        else:
-            desc = ""
-        return desc + self.format_option_help(formatter)
+            result.append(self.format_description(formatter))
+        if self.option_list:
+            result.append(self.format_option_help(formatter))
+        return "\n".join(result)

I also noticed that the test suite doesn't pass any longer.
I can clean it up (make it pass) while I'm at it.  Ought to be
synched with the Python test_optparse.py too.

-- 
David Goodger    http://starship.python.net/~goodger
For hire: http://starship.python.net/~goodger/cv
Docutils: http://docutils.sourceforge.net/
(includes reStructuredText: http://docutils.sf.net/rst.html)



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf