Make EvTable.add_row forward row-options correctly. Resolve #2389.

This commit is contained in:
Griatch 2021-08-16 21:10:44 +02:00
parent 819097fdde
commit a4cabd9306

View file

@ -308,7 +308,7 @@ def fill(text, width=_DEFAULT_WIDTH, **kwargs):
# EvCell class (see further down for the EvTable itself)
class EvCell(object):
class EvCell:
"""
Holds a single data cell for the table. A cell has a certain width
and height and contains one or more lines of data. It can shrink
@ -976,14 +976,17 @@ class EvColumn(object):
Available keywods as per `EvCell.__init__`.
"""
# column-level options override those in kwargs
options = {**kwargs, **self.options}
ypos = kwargs.get("ypos", None)
if ypos is None or ypos > len(self.column):
# add to the end
self.column.extend([EvCell(data, **self.options) for data in args])
self.column.extend([EvCell(data, **options) for data in args])
else:
# insert cells before given index
ypos = min(len(self.column) - 1, max(0, int(ypos)))
new_cells = [EvCell(data, **self.options) for data in args]
new_cells = [EvCell(data, **options) for data in args]
self.column = self.column[:ypos] + new_cells + self.column[ypos:]
# self._balance(**kwargs)
@ -1010,6 +1013,7 @@ class EvColumn(object):
Keywords as per `EvCell.__init__`.
"""
# column-level options take precedence here
kwargs.update(self.options)
self.column[index].reformat(**kwargs)