from tabulate import tabulate


def return_pyvpc_objects_string(pyvpc_objects):
    """
    Documentation https://github.com/astanin/python-tabulate
    :param pyvpc_objects: list of PyVPCBlock
    :return: string
    """

    table = []
    # Prepare the table list, that contains lists of values
    for pyvpc_object in pyvpc_objects:
        table.append([pyvpc_object.get_start_address(), pyvpc_object.get_end_address(),
                      pyvpc_object.get_num_addresses(), pyvpc_object.get_network_prefix(),
                      pyvpc_object.block_available, pyvpc_object.get_id(), pyvpc_object.get_name()])

    # Make sure headers are aligned with number of values is 'table'
    headers = ["Lowest IP", "Upper IP", "Num of Addr", "Prefix", "Available", "ID", "Name"]

    return tabulate(table, headers, tablefmt="github")