Display formatted notes in info output v0.6.x
authormartin f. krafft <madduck@madduck.net>
Sat, 14 Apr 2012 22:52:40 +0200
branchv0.6.x
changeset 542 c3b98364f03d
parent 541 a582f1452bc0
child 543 1b3bdce0bf87
Display formatted notes in info output If the user/domain object has an attached note, this patch makes the userinfo/domaininfo output print the note, wrapped to the terminal size.
VirtualMailManager/cli/subcommands.py
--- a/VirtualMailManager/cli/subcommands.py	Sat Apr 14 21:20:06 2012 +0200
+++ b/VirtualMailManager/cli/subcommands.py	Sat Apr 14 22:52:40 2012 +0200
@@ -898,7 +898,22 @@
         else:
             w_std(u'\t%s: %s' % (key.title().ljust(17, u'.'), info[key]))
     print
+    note = info.get('note', None)
+    if note is not None:
+        _print_note(note)
 
+def _print_note(note):
+    msg = _(u'Note')
+    w_std(msg, u'-' * len(msg))
+    old_ii = txt_wrpr.initial_indent
+    old_si = txt_wrpr.subsequent_indent
+    txt_wrpr.initial_indent = txt_wrpr.subsequent_indent = '\t'
+    txt_wrpr.width -= 8
+    for para in note.split('\n'):
+        w_std(txt_wrpr.fill(para))
+    txt_wrpr.width += 8
+    txt_wrpr.subsequent_indent = old_si
+    txt_wrpr.initial_indent = old_ii
 
 def _print_list(alist, title):
     """Print a list."""