Skip to content

Commit

Permalink
Fix table widths and headers for beautifultable 1.0.0 (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 authored Sep 30, 2020
1 parent 88a8f05 commit e52747c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"click>=7.0",
"click-default-group",
"keyring>=18.0.0",
"beautifultable>=0.8.0",
"beautifultable>=1.0.0",
"humanize>=0.5.1"
]
},
Expand Down
8 changes: 4 additions & 4 deletions src/cli/formatters/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class TabularFormatter(ObjectFormatter):
def format_attr_table(self, data):
term_width, term_height = click.get_terminal_size()
table = beautifultable.BeautifulTable(max_width=term_width,
table = beautifultable.BeautifulTable(maxwidth=term_width,
default_alignment=beautifultable.ALIGN_LEFT)
table.set_style(beautifultable.STYLE_NONE)
for key, formatter, value in data:
Expand All @@ -27,15 +27,15 @@ def format_attr_table(self, data):

def format_table(self, headers, widths, row_formatter, rows):
term_width, term_height = click.get_terminal_size()
table = beautifultable.BeautifulTable(max_width=term_width,
table = beautifultable.BeautifulTable(maxwidth=term_width,
default_alignment=beautifultable.ALIGN_LEFT)
table.column_headers = headers
table.columns.header = headers
sum_width = None
for width_set in widths:
column_widths, expandable_index = width_set[:-1], width_set[-1]
sum_width = sum(column_widths) + 6 # Table characters width
if term_width > sum_width:
table._column_widths = (
table.columns.width = (
column_widths[:expandable_index] +
[term_width - sum_width + column_widths[expandable_index]] +
column_widths[expandable_index+1:]
Expand Down

0 comments on commit e52747c

Please sign in to comment.