From bad531679aacdc4a9051b2a87458f27251b6c9e2 Mon Sep 17 00:00:00 2001 From: Florent Date: Mon, 21 May 2012 17:46:21 +0200 Subject: [PATCH] Fix table formatter with 0.6 version I didn't see a way to only align header... --- weboob/tools/application/formatters/table.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/weboob/tools/application/formatters/table.py b/weboob/tools/application/formatters/table.py index d11dc11d..55e74688 100644 --- a/weboob/tools/application/formatters/table.py +++ b/weboob/tools/application/formatters/table.py @@ -69,7 +69,13 @@ class TableFormatter(IFormatter): s += "\n" table = PrettyTable(list(column_headers)) for column_header in column_headers: - table.set_field_align(column_header, 'l') + # API changed in python-prettytable. The try/except is a bad hack to support both versions + # Note: two versions are not exactly the same... + # (first one: header in center. Second one: left align for header too) + try: + table.set_field_align(column_header, 'l') + except: + table.align[column_header] = 'l' for line in queue: table.add_row(line)