Example #1
0
    def test_map_col(self):
        table = TempyTable(data=self.data)

        table.map_col(lambda x: x - 1)
        self.assertEqual(-1, table.childs[0].childs[0].childs[0].childs[0])

        # applies function x - 2 for second column
        table.map_col(lambda x: x - 2, 1)
        self.assertEqual(-3, table.childs[0].childs[0].childs[1].childs[0])
Example #2
0
table4 = TempyTable(data=data, caption='User information4', width='50%')

table2.pop_cell()
special_cell.append_to(table2.childs[0].childs[2])

css_tag = Css({
                '.class_example_1': {'color': 'blue'},
                '.class_example_2': {'color': 'pink'},
                '.class_example_3': {'background-color': 'grey'},
          })

# set class for every cell
table1.col_class('class_example_2')

# applies function to upper string for every cell
table1.map_col(lambda x: x.upper())

# set class for first column of each row
table2.col_class('class_example_1', 0)

# applies function to lower string for second column
table2.map_col(lambda x: x.lower(), 1)

# applies function to upper string for last column
table2.map_col(lambda x: x.upper(), 4)

# set class for every row
table3.row_class('class_example_3')

# applies function to upper string for every row
table3.map_row(lambda x: x.upper())