summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-04-23 11:52:44 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-04-23 11:52:44 -0400
commit9cd1a68749bd3f007e209d6c0a3ee8549f4d22c3 (patch)
tree2266a089b525bd6783cee115d3a04ecbce1176ed
parent07096c454d3a75a868f86ba8ce2f3678af934808 (diff)
downloadbcfg2-9cd1a68749bd3f007e209d6c0a3ee8549f4d22c3.tar.gz
bcfg2-9cd1a68749bd3f007e209d6c0a3ee8549f4d22c3.tar.bz2
bcfg2-9cd1a68749bd3f007e209d6c0a3ee8549f4d22c3.zip
cleaner handling of line-wrapping in bcfg2-lint
-rw-r--r--src/lib/Bcfg2/Server/Lint/__init__.py17
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)