Skip to content

Commit

Permalink
Handle empty row gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesls committed Apr 10, 2013
1 parent 7f32cfa commit d0a259c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions awscli/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ def _render_rows(self, section, max_width, stream):
return
widths = section.calculate_column_widths(padding=4,
max_width=max_width)
if not widths:
return
self._write_line_break(stream, widths)
for row in section.rows:
# TODO: Built the string in a list then join instead of using +=,
Expand Down Expand Up @@ -336,6 +338,8 @@ def calculate_column_widths(self, padding=0, max_width=None):
unscaled_widths = [w + padding for w in self._max_widths]
if max_width is None:
return unscaled_widths
if not unscaled_widths:
return unscaled_widths
else:
# Compute scale factor for max_width.
scale_factor = max_width / float(sum(unscaled_widths))
Expand Down

0 comments on commit d0a259c

Please sign in to comment.