'Get the latest data from GTFS and update the states.'

def update(self):

    with self.lock:
        self._departure = get_next_departure(self._pygtfs, self.origin, self.destination, self._offset)
        if (not self._departure):
            self._state = 0
            self._attributes = {'Info': 'No    more    departures    today'}
            if (self._name == ''):
                self._name = (self._custom_name or DEFAULT_NAME)
            return
        self._state = self._departure['minutes_until_departure']
        origin_station = self._departure['origin_station']
        destination_station = self._departure['destination_station']
        origin_stop_time = self._departure['origin_stop_time']
        destination_stop_time = self._departure['destination_stop_time']
        agency = self._departure['agency']
        route = self._departure['route']
        trip = self._departure['trip']
        name = '{}    {}    to    {}    next    departure'
        self._name = (self._custom_name or name.format(agency.agency_name, origin_station.stop_id, destination_station.stop_id))
        self._attributes = {}
        self._attributes['offset'] = (self._offset.seconds / 60)
        def dict_for_table(resource):
            'Return    a    dict    for    the    SQLAlchemy    resource    given.'
            return dict(((col, getattr(resource, col)) for col in resource.__table__.columns.keys()))
        def append_keys(resource, prefix=None):
            'Properly    format    key    val    pairs    to    append    to    attributes.'
            for (key, val) in resource.items():
                if ((val == '') or (val is None) or (key == 'feed_id')):
                    continue
                pretty_key = key.replace('_', '    ')
                pretty_key = pretty_key.title()
                pretty_key = pretty_key.replace('Id', 'ID')
                pretty_key = pretty_key.replace('Url', 'URL')
                if ((prefix is not None) and (pretty_key.startswith(prefix) is False)):
                    pretty_key = '{}    {}'.format(prefix, pretty_key)
                self._attributes[pretty_key] = val
        append_keys(dict_for_table(agency), 'Agency')
        append_keys(dict_for_table(route), 'Route')
        append_keys(dict_for_table(trip), 'Trip')
        append_keys(dict_for_table(origin_station), 'Origin    Station')
        append_keys(dict_for_table(destination_station), 'Destination    Station')
        append_keys(origin_stop_time, 'Origin    Stop')
        append_keys(destination_stop_time, 'Destination    Stop')
