Get all real-time departure times for given stop and return as filtered table.

    Terminate if we can assume there is no connection to the internet.

def get_next_departures(stop, filter_line=None, num_line_groups=1, verbose=False):
    """
    Get all real-time departure times for given stop and return as filtered table.

    Terminate if we can assume there is no connection to the internet. 
    """

    # Get departures table from online service
    # (great: we don't have to iterate over multiple pages).

    url = BVG_URL_PAT % stop
    if verbose:
        print('- Fetching table for URL "%s".' % url)
    try:
        tables = pd.read_html(url.encode('utf-8'))
    except urllib.error.URLError:
        msg = 'Not connected to the internet?'
        termcolor.cprint(msg, 'red', attrs=['bold'])
        sys.exit(1)
    except ValueError:
        return []
    table = tables[0]
    table.columns = ['Departure', 'Line', 'Destination']

    if verbose:
        print('- Got table with %d entries for "%s".' % (len(table), stop))

    # Cleanup

    # Drop entries with '*' in column Departure...
    # (causes trouble when resulting in an empty table!)
    # table = table[table.Departure.apply(lambda row: " *" not in row)]
    # So, instead remove '*' in column Departure...
    table.is_copy = False # prevents SettingWithCopyWarning
    table.Departure = table.apply(
        lambda row: re.sub('\s*\*\s*', '', row.Departure), axis=1)

    # Replace regex ' +' with ' ' in column Line...
    table.Line = table.apply(lambda row: re.sub(' +', ' ', row.Line), axis=1)

    # Filter desired number of unique combinations of Line and Destination column.
    indices = []
    for i in range(num_line_groups):
        try:
            indices += sorted([tab.index.values[i] 
                for line_dest, tab in table.groupby(['Line', 'Destination'])])
        except IndexError:
            break
    table = table[table.index.map(lambda x: x in indices)]

    # Insert a left-most column with minutes and seconds from now 
    # until the departure time.
    table.insert(0, "Wait", table.Departure.apply(lambda dep: wait_time(dep)))

    # Filter on desired lines only
    if filter_line:
        table = table[table.Line.apply(
            lambda cell: filter_line.lower().encode('utf-8') in cell.lower())]

    return table