Skip to content

Commit 8e32fd5

Browse files
committed
Tweaked so that object formatter and display formatter functions can be chained together.
This allows an value generated by an object formatter to be passed to an existing display formatter function. For example, this allows a computed float value to from an object formatter to go through a display formatter to round/truncate digits.
1 parent 2b45af1 commit 8e32fd5

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

tableformatter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,8 @@ def generate_table(self, entries: Iterable[Union[Iterable, object]], force_trans
928928
formatter = self._get_column_option(column_index, TableFormatter.COL_OPT_FIELD_FORMATTER)
929929
obj_formatter = self._get_column_option(column_index, TableFormatter.COL_OPT_OBJECT_FORMATTER)
930930
if obj_formatter is not None and callable(obj_formatter):
931-
field_string = obj_formatter(entry_obj)
932-
elif formatter is not None and callable(formatter):
931+
field_obj = obj_formatter(entry_obj)
932+
if formatter is not None and callable(formatter):
933933
field_string = formatter(field_obj)
934934
elif isinstance(field_obj, str):
935935
field_string = field_obj
@@ -959,8 +959,8 @@ def generate_table(self, entries: Iterable[Union[Iterable, object]], force_trans
959959
formatter = self._get_column_option(column_index, TableFormatter.COL_OPT_FIELD_FORMATTER)
960960
obj_formatter = self._get_column_option(column_index, TableFormatter.COL_OPT_OBJECT_FORMATTER)
961961
if obj_formatter is not None and callable(obj_formatter):
962-
field_string = obj_formatter(entry)
963-
elif formatter is not None and callable(formatter):
962+
field = obj_formatter(entry)
963+
if formatter is not None and callable(formatter):
964964
field_string = formatter(field, )
965965
elif isinstance(field, str):
966966
field_string = field

0 commit comments

Comments
 (0)