def get_table ( ports ) : table = PrettyTable ( [ "Name" , "Port" , "Protocol" , "Description" ] ) table . align [ "Name" ] = "l" table . align [ "Description" ] = "l" table . padding_width = 1 for port in ports : table . add_row ( port ) return table
print as formatted table python
This function returns a pretty table used to display the port results .
def get_table(ports):
    """
    This function returns a pretty table used to display the port results.

    :param ports: list of found ports
    :return: the table to display
    """
    table = PrettyTable(["Name", "Port", "Protocol", "Description"])
    table.align["Name"] = "l"
    table.align["Description"] = "l"
    table.padding_width = 1

    for port in ports:
        table.add_row(port)

    return table