Restructure severity help function to match status
authorTim Guirgies <lt.infiltrator@gmail.com>
Tue, 24 May 2011 16:15:11 +0000 (02:15 +1000)
committerW. Trevor King <wking@drexel.edu>
Wed, 25 May 2011 10:24:27 +0000 (06:24 -0400)
The code structure was vastly different in severity.py to status.py, so
I mostly copied the structure from there and adjusted it to suit
severity.

The structure in status.py looked (to me) cleaner, more organised, and
easier to work with.

Also, users are now referred by "be severity --help" to "be set --help",
in a manner similar to "be status --help".
For those that don't know that severity can be adjusted on a per
repository basis, this seems extremely helpful. A similar message
appears for status, but not here.

libbe/command/severity.py

index a84efe84968be6a9db53a12efab2a5feae409aa5..c510bc4149e6f2d63ab3750e546d7e497d5ba365 100644 (file)
@@ -79,21 +79,26 @@ class Severity (libbe.command.Command):
         return 0
 
     def _long_help(self):
-        ret = ["""
-Show or change a bug's severity level.
-
-If no severity is specified, the current value is printed.  If a severity level
-is specified, it will be assigned to the bug.
-
-Severity levels are:
-"""]
         try: # See if there are any per-tree severity configurations
             bd = self._get_bugdir()
         except NotImplementedError:
             pass # No tree, just show the defaults
         longest_severity_len = max([len(s) for s in libbe.bug.severity_values])
+        severity_levels = []
         for severity in libbe.bug.severity_values :
             description = libbe.bug.severity_description[severity]
-            ret.append('%*s : %s\n' \
-                % (longest_severity_len, severity, description))
-        return ''.join(ret)
+            s = '%*s : %s' % (longest_severity_len, severity, description)
+            severity_levels.append(s)
+        ret = """
+Show or change a bug's severity level.
+
+If no severity is specified, the current value is printed.  If a severity level
+is specified, it will be assigned to the bug.
+
+Severity levels are:
+  %s
+
+You can overide the list of allowed severities on a per-repository basis.
+See "be set --help" for more details.
+""" % ('\n  '.join(severity_levels))
+        return ret