mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-24 16:10:02 -06:00
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.
This commit is contained in:
parent
d4bf153d64
commit
453d88f886
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user