Get the latest data from Transport NSW.
186488
def get_departures(self, stop_id, route, destination, api_key):
        """"""
        self.stop_id = stop_id
        self.route = route
        self.destination = destination
        self.api_key = api_key

        # Build the URL including the STOP_ID and the API key
        url = \
            'https://api.transport.nsw.gov.au/v1/tp/departure_mon?' \
            'outputFormat=rapidJSON&coordOutputFormat=EPSG%3A4326&' \
            'mode=direct&type_dm=stop&name_dm=' \
            + self.stop_id \
            + '&departureMonitorMacro=true&TfNSWDM=true&version=10.2.1.42'
        auth = 'apikey ' + self.api_key
        header = {'Accept': 'application/json', 'Authorization': auth}

        # Send query or return error
        try:
            response = requests.get(url, headers=header, timeout=10)
        except:
            logger.warning("Network or Timeout error")
            return self.info

        # If there is no valid request
        if response.status_code != 200:
            logger.warning("Error with the request sent; check api key")
            return self.info

        # Parse the result as a JSON object
        result = response.json()

        # If there is no stop events for the query
        try:
            result['stopEvents']
        except KeyError:
            logger.warning("No stop events for this query")
            return self.info

        # Set variables
        maxresults = 1
        monitor = []
        if self.destination != '':
            for i in range(len(result['stopEvents'])):
                destination = result['stopEvents'][i]['transportation']['destination']['name']
                if destination == self.destination:
                    event = self.parseEvent(result, i)
                    if event != None:
                        monitor.append(event)
                    if len(monitor) >= maxresults:
                        # We found enough results, lets stop
                        break
        elif self.route != '':
            # Find the next stop events for a specific route
            for i in range(len(result['stopEvents'])):
                number = result['stopEvents'][i]['transportation']['number']
                if number == self.route:
                    event = self.parseEvent(result, i)
                    if event != None:
                        monitor.append(event)
                    if len(monitor) >= maxresults:
                        # We found enough results, lets stop
                        break
        else:
            # No route defined, find any route leaving next
            for i in range(0, maxresults):
                event = self.parseEvent(result, i)
                if event != None:
                    monitor.append(event)
        if monitor:
            self.info = {
                ATTR_STOP_ID: self.stop_id,
                ATTR_ROUTE: monitor[0][0],
                ATTR_DUE_IN: monitor[0][1],
                ATTR_DELAY: monitor[0][2],
                ATTR_REALTIME: monitor[0][5],
                ATTR_DESTINATION: monitor[0][6],
                ATTR_MODE: monitor[0][7]
                }
        return self.info
1355691
def get_last_doc(self):
        """"""
        return max(self.doc_dict.values(), key=lambda x: x.ts).meta_dict
1044071
def get_data(self):
		""
		array = ctypes.POINTER(ctypes.c_char * len(self))
		return ctypes.cast(self.data, array).contents.raw
554994
def lastProgress(self):
        
        lastProgress = self._jsq.lastProgress()
        if lastProgress:
            return json.loads(lastProgress.json())
        else:
            return None
984628
def data_raw(self):
    """"""
    return self._client.send(data=sc_pb.RequestData(
        ability_id=True, unit_type_id=True))
40148
def data(self, key=None, **kwargs):
        """"""
        self.content_data.update(kwargs)
        if key:
            return self.content_data[key]
        if not kwargs:
            return self.content_data
        return self
263933
async def getStats(self):
        
        self.__stats.add(RTCOutboundRtpStreamStats(
            # RTCStats
            timestamp=clock.current_datetime(),
            type='outbound-rtp',
            id='outbound-rtp_' + str(id(self)),
            # RTCStreamStats
            ssrc=self._ssrc,
            kind=self.__kind,
            transportId=self.transport._stats_id,
            # RTCSentRtpStreamStats
            packetsSent=self.__packet_count,
            bytesSent=self.__octet_count,
            # RTCOutboundRtpStreamStats
            trackId=str(id(self.track)),
        ))
        self.__stats.update(self.transport._get_stats())

        return self.__stats
511231
def get_trips(self, authentication_info, start, end):
        """"""
        import requests

        if (authentication_info is None or
            not authentication_info.is_valid()):
            return []

        data_url = "https://api.ritassist.nl/api/trips/GetTrips"
        query = f"?equipmentId={self.identifier}&from={start}&to={end}&extendedInfo=True"
        header = authentication_info.create_header()
        response = requests.get(data_url + query, headers=header)
        trips = response.json()

        result = []
        for trip_json in trips:
            trip = Trip(trip_json)
            result.append(trip)
        return result
709639
def fetch_last(response: Response) -> typing.Union[str, None]:
    

    recent_paths = environ.configs.fetch('recent_paths', [])

    if len(recent_paths) < 1:
        response.fail(
            code='NO_RECENT_PROJECTS',
            message='No projects have been opened recently'
        ).console()
        return None

    return recent_paths[0]
48537
def retrieve(self):
        

        data = self.resource(self.id).get()
        self.data = data

        return data
963770
def _itemsLoadedDone(self, data):
        
        if data is None:
            return
        self.continuation   = data.get('continuation', None)
        self.lastUpdated    = data.get('updated', None)
        self.lastLoadLength = len(data.get('items', []))
        self.googleReader.itemsToObjects(self, data.get('items', []))
        self.lastLoadOk = True
432816
def get_data(self):
        """"""
        # Count level(shortest path to root) and depth(longest path to root)
        # values for all unique GO Terms.
        data = []
        ntobj = cx.namedtuple("NtGoCnt", "Depth_Level BP_D MF_D CC_D BP_L MF_L CC_L")
        cnts = self.get_cnts_levels_depths_recs(set(self.obo.values()))
        max_val = max(max(dep for dep in cnts['depth']), max(lev for lev in cnts['level']))
        for i in range(max_val+1):
            vals = [i] + [cnts[desc][i][ns] for desc in cnts for ns in self.nss]
            data.append(ntobj._make(vals))
        return data
246577
def get_last_modified_date(
            self,
            bucket: str,
            key: str,
    ) -> datetime:
        
        response = self.get_all_metadata(bucket, key)
        return response['LastModified']
989850
def get_traffic_items(self):
        

        traffic = self.get_child_static('traffic')
        return {o.obj_name(): o for o in traffic.get_objects_or_children_by_type('trafficItem')}
156125
def grab_next(self, timeout: float=None) -> typing.List[DataAndMetadata.DataAndMetadata]:
        """"""
        with self.__buffer_lock:
            self.__buffer = list()
        return self.grab_latest(timeout)
13668
def get_all_current_trains(self, train_type=None, direction=None):
        
        params = None
        if train_type:
            url = self.api_base_url + 'getCurrentTrainsXML_WithTrainType'
            params = {
                'TrainType': STATION_TYPE_TO_CODE_DICT[train_type]
            }
        else:
            url = self.api_base_url + 'getCurrentTrainsXML'

        response = requests.get(
            url, params=params, timeout=10)

        if response.status_code != 200:
            return []

        trains = self._parse_all_train_data(response.content)

        if direction is not None:
            return self._prune_trains(trains, direction=direction)

        return trains
181266
def data(self):
        
        # Cache the data for next time .data is called.
        if self._data is None:
            self._data = self.to_value(self.instance)
        return self._data