minor refactoring and trivial bug fix

This commit is contained in:
Bernardo Damele 2013-02-06 17:45:25 +00:00
parent e439c3d3f5
commit 477c66ac4b

View File

@ -90,22 +90,22 @@ class Dump(object):
def string(self, header, data, content_type=None, sort=True): def string(self, header, data, content_type=None, sort=True):
kb.stickyLevel = None kb.stickyLevel = None
if hasattr(conf, "api"):
self._write(data, content_type=content_type)
return
if isListLike(data): if isListLike(data):
self.lister(header, data, sort) self.lister(header, data, content_type, sort)
elif data is not None: elif data is not None:
_ = getUnicode(data) _ = getUnicode(data)
if _ and _[-1] == '\n': if _ and _[-1] == '\n':
_ = _[:-1] _ = _[:-1]
if hasattr(conf, "api"): if "\n" in _:
self._write(data, content_type=content_type)
elif "\n" in _:
self._write("%s:\n---\n%s\n---" % (header, _)) self._write("%s:\n---\n%s\n---" % (header, _))
else: else:
self._write("%s: %s" % (header, ("'%s'" % _) if isinstance(data, basestring) else _)) self._write("%s: %s" % (header, ("'%s'" % _) if isinstance(data, basestring) else _))
elif hasattr(conf, "api"):
self._write(data, content_type=content_type)
else: else:
self._write("%s:\tNone" % header) self._write("%s:\tNone" % header)