handle an empty data set

This commit is contained in:
Doug Hellmann 2012-04-27 19:23:26 -04:00
parent 216079ee59
commit b8f3ad548d
1 changed files with 12 additions and 8 deletions

View File

@ -32,7 +32,11 @@ class TableLister(ListFormatter):
# first row and set the alignment of the
# output accordingly.
data_iter = iter(data)
try:
first_row = next(data_iter)
except StopIteration:
pass
else:
for value, name in zip(first_row, column_names):
alignment = self.ALIGNMENTS.get(type(value), 'l')
x.set_field_align(name, alignment)