diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-04-23 11:52:44 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-04-23 11:52:44 -0400 |
commit | 9cd1a68749bd3f007e209d6c0a3ee8549f4d22c3 (patch) | |
tree | 2266a089b525bd6783cee115d3a04ecbce1176ed /src/lib/Bcfg2/Server | |
parent | 07096c454d3a75a868f86ba8ce2f3678af934808 (diff) | |
download | bcfg2-9cd1a68749bd3f007e209d6c0a3ee8549f4d22c3.tar.gz bcfg2-9cd1a68749bd3f007e209d6c0a3ee8549f4d22c3.tar.bz2 bcfg2-9cd1a68749bd3f007e209d6c0a3ee8549f4d22c3.zip |
cleaner handling of line-wrapping in bcfg2-lint
Diffstat (limited to 'src/lib/Bcfg2/Server')
-rw-r--r-- | src/lib/Bcfg2/Server/Lint/__init__.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/lib/Bcfg2/Server/Lint/__init__.py b/src/lib/Bcfg2/Server/Lint/__init__.py index 3a86709c0..f3991e3fc 100644 --- a/src/lib/Bcfg2/Server/Lint/__init__.py +++ b/src/lib/Bcfg2/Server/Lint/__init__.py @@ -96,7 +96,6 @@ class Plugin (object): class ErrorHandler (object): - # how to handle different errors by default def __init__(self, config=None): self.errors = 0 self.warnings = 0 @@ -105,11 +104,12 @@ class ErrorHandler (object): termsize = get_termsize() if termsize is not None: - self._wrapper = textwrap.TextWrapper(initial_indent=" ", - subsequent_indent=" ", - width=termsize[0]) + twrap = textwrap.TextWrapper(initial_indent=" ", + subsequent_indent=" ", + width=termsize[0]) + self._wrapper = twrap.wrap else: - self._wrapper = None + self._wrapper = lambda s: [s] self._handlers = {} if config is not None: @@ -166,13 +166,10 @@ class ErrorHandler (object): rawlines = msg.splitlines() firstline = True for rawline in rawlines: - if self._wrapper: - lines = self._wrapper.wrap(rawline) - else: - lines = [rawline] + lines = self._wrapper(rawline) for line in lines: if firstline: - logfunc("%s%s" % (prefix, line.lstrip())) + logfunc(prefix + line.lstrip()) firstline = False else: logfunc(line) |