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.
--- 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."""