class GttData: """Inteface to PyGTT.""" def __init__(self, stop, bus_name): """Initialize the GttData class.""" from pygtt import PyGTT self._pygtt = PyGTT() self._stop = stop self._bus_name = bus_name self.bus_list = {} self.state_bus = {} def get_data(self): """Get the data from the api.""" self.bus_list = self._pygtt.get_by_stop(self._stop) self.bus_list.sort(key=get_datetime) if self._bus_name is not None: self.state_bus = self.get_bus_by_name() return self.state_bus = self.bus_list[0] def get_bus_by_name(self): """Get the bus by name.""" for bus in self.bus_list: if bus['bus_name'] == self._bus_name: return bus
class GttData: """Inteface to PyGTT.""" def __init__(self, stop, bus_name): """Initialize the GttData class.""" from pygtt import PyGTT self._pygtt = PyGTT() self._stop = stop self._bus_name = bus_name self.bus_list = {} self.state_bus = {} def get_data(self): """Get the data from the api.""" self.bus_list = self._pygtt.get_by_stop(self._stop) self.bus_list.sort(key=get_datetime) if self._bus_name is not None: self.state_bus = self.get_bus_by_name() return self.state_bus = self.bus_list[0] def get_bus_by_name(self): """Get the bus by name.""" for bus in self.bus_list: if bus["bus_name"] == self._bus_name: return bus
from pygtt import PyGTT p = PyGTT() print(p.get_by_stop(108))