diff options
author | Tomas Babej <tbabej@redhat.com> | 2013-08-06 12:52:03 +0200 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2013-08-06 15:54:48 +0200 |
commit | 453d88f88603074651a0b8bcd7d867ca05f1cb70 (patch) | |
tree | 0d1f1d4ce451ba6f65263ba0f18a447b8c185118 /ipaserver/advise | |
parent | d4bf153d646807b42f38bccbc19cd2690b5622bc (diff) | |
download | freeipa-453d88f88603074651a0b8bcd7d867ca05f1cb70.tar.gz freeipa-453d88f88603074651a0b8bcd7d867ca05f1cb70.tar.xz freeipa-453d88f88603074651a0b8bcd7d867ca05f1cb70.zip |
Wrap lines in the list of available advices
Now the list of available advices is neatly formatted:
-------------------------
List of available advices
-------------------------
config-fedora-authconfig : Authconfig instructions for configuring Fedora
18/19 client with IPA server without use of SSSD.
The advice header printing has been reformatted to conform with the changes.
Diffstat (limited to 'ipaserver/advise')
-rw-r--r-- | ipaserver/advise/base.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/ipaserver/advise/base.py b/ipaserver/advise/base.py index b26bbc6b..5a55c3de 100644 --- a/ipaserver/advise/base.py +++ b/ipaserver/advise/base.py @@ -22,6 +22,7 @@ import os from ipalib import api from ipalib.errors import ValidationError from ipapython import admintool +from textwrap import wrap """ @@ -112,9 +113,15 @@ class IpaAdvise(admintool.AdminTool): # Compute the number of spaces needed for the table to be aligned offset = max_keyword_len - len(keyword) - print(" {key} {off}: {desc}".format(key=keyword, - desc=description, - off=' ' * offset)) + prefix = " {key} {off}: ".format(key=keyword, off=' ' * offset) + wrapped_description = wrap(description, 80 - len(prefix)) + + # Print the first line with the prefix (keyword) + print prefix + wrapped_description[0] + + # Print the rest wrapped behind the colon + for line in wrapped_description[1:]: + print "{off}{line}".format(off=' ' * len(prefix), line=line) def print_header(self, header, print_shell=False): header_size = len(header) @@ -126,9 +133,10 @@ class IpaAdvise(admintool.AdminTool): # Do not print out empty header if header_size > 0: - print(prefix + '-' * (header_size - len(prefix))) - print(prefix + header) - print(prefix + '-' * (header_size - len(prefix))) + print(prefix + '-' * 70) + for line in wrap(header, 70): + print(prefix + line) + print(prefix + '-' * 70) def print_advice(self, keyword): advice = getattr(api.Advice, keyword, None) |