summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorTomas Babej <tbabej@redhat.com>2013-08-06 12:27:53 +0200
committerMartin Kosek <mkosek@redhat.com>2013-08-06 15:54:47 +0200
commitd4bf153d646807b42f38bccbc19cd2690b5622bc (patch)
tree0c91bd1b137115ccb9e57b6831319d027287a96b /ipalib
parent8c8da71ea38c0082884c193c699a9f5d20b7e898 (diff)
downloadfreeipa-d4bf153d646807b42f38bccbc19cd2690b5622bc.tar.gz
freeipa-d4bf153d646807b42f38bccbc19cd2690b5622bc.tar.xz
freeipa-d4bf153d646807b42f38bccbc19cd2690b5622bc.zip
Add a word wrapping for comment log messages to AdviceLogger
The comments logged through AdviceLogger are now wrapped up to 70 characters. This change has been documented in the docstrings.
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/frontend.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index 67ca7767c..cac3e3b39 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -35,6 +35,7 @@ from errors import (ZeroArgumentError, MaxArgumentError, OverlapError,
VersionError, OptionError, InvocationError,
ValidationError, ConversionError)
from ipalib import messages
+from textwrap import wrap
RULE_FLAG = 'validation_rule'
@@ -1454,8 +1455,12 @@ class _AdviceOutput(object):
self.prefix = '# '
self.options = None
- def comment(self, line):
- self.content.append(self.prefix + line)
+ def comment(self, line, wrapped=True):
+ if wrapped:
+ for wrapped_line in wrap(line, 70):
+ self.content.append(self.prefix + wrapped_line)
+ else:
+ self.content.append(self.prefix + line)
def debug(self, line):
if self.options.verbose: