

def Filter(self, function=None):
    "Construct Textable from the rows of which the function returns true.\n\n\n    Args:\n      function: A function applied to each row which returns a bool. If\n                function is None, all rows with empty column values are\n                removed.\n    Returns:\n      A new TextTable()\n\n    Raises:\n      TableError: When an invalid row entry is Append()'d\n    "
    flat = (lambda x: (x if isinstance(x, str) else ''.join([flat(y) for y in x])))
    if (function is None):
        function = (lambda row: bool(flat(row.values)))
    new_table = self.__class__()
    new_table._table = [self.header]
    for row in self:
        if (function(row) is True):
            new_table.Append(row)
    return new_table

dataset/ETHPy150Open google/textfsm/texttable.py TextTable.Filter/original