From cbd02a494174ddf7d79594b53c016bae8ea62194 Mon Sep 17 00:00:00 2001 From: Niru Maheswaranathan Date: Tue, 1 Dec 2015 12:59:48 -0800 Subject: [PATCH] fixed bug where extra hr's were printed --- tableprint.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tableprint.py b/tableprint.py index 06d38e1..b42d97b 100644 --- a/tableprint.py +++ b/tableprint.py @@ -14,7 +14,7 @@ except ImportError: # exports __all__ = ['table', 'row', 'header', 'hr', 'humantime', 'frame'] -__version__ = '0.1.8' +__version__ = '0.1.9' def table(data, headers, format_spec='5g', column_width=10, outer_char='|', corner_char='+', line_char='-'): @@ -47,20 +47,17 @@ def table(data, headers, format_spec='5g', column_width=10, outer_char='|', corn """ - # the hr line - hrule = hr(len(headers), column_width=column_width, - corner_char=corner_char, line_char=line_char) - # get the header string - headerstr = [hrule, header(headers, column_width=column_width, outer_char=outer_char), hrule] + headerstr = header(headers, column_width=column_width, outer_char=outer_char) # parse each row - tablestr = headerstr + [row(d, column_width=column_width, format_spec=format_spec, - outer_char=outer_char) for d in data]\ + tablestr = [headerstr] + [row(d, column_width=column_width, format_spec=format_spec, + outer_char=outer_char) for d in data] # only add the final border if there was data in the table if len(data) > 0: - tablestr += [hrule] + tablestr += [hr(len(headers), column_width=column_width, + corner_char=corner_char, line_char=line_char)] # print the table print('\n'.join(tablestr))