diff options
Diffstat (limited to 'qtip/reporter/filters.py')
-rw-r--r-- | qtip/reporter/filters.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/qtip/reporter/filters.py b/qtip/reporter/filters.py index c0c379df..52b34bc6 100644 --- a/qtip/reporter/filters.py +++ b/qtip/reporter/filters.py @@ -8,7 +8,16 @@ ############################################################################## -def justify(pair, width=80, padding_with='.'): +def _justify_pair(pair, width=80, padding_with='.'): """align first element along the left margin, second along the right, padding spaces""" n = width - len(pair[0]) return '{key}{value:{c}>{n}}'.format(key=pair[0], value=pair[1], c=padding_with, n=n) + + +def justify(content, width=80, padding_with='.'): + if isinstance(content, list): + return '\n'.join([justify(item, width, padding_with) for item in content]) + elif isinstance(content, dict): + return '\n'.join([justify(item, width, padding_with) for item in content.items()]) + else: + return _justify_pair(content, width, padding_with) |