fixed potential error in TriMetVehicle class.

added notes
This commit is contained in:
Arris Kathery 2024-05-11 16:18:47 -07:00
parent eb9f12ca42
commit b800e064a3
2 changed files with 12 additions and 5 deletions

1
NOTES.txt Normal file
View file

@ -0,0 +1 @@
for developer information, check my documentation repo at https://basedwa.re/elburg/bibliotheca/src/branch/en-US/opentrans

View file

@ -1,6 +1,11 @@
# Developer home: https://developer.trimet.org/ "00BA96108889B7ED8850997D7" """
TriMet API Wrapper
Author(s): Arris Kathery <whotookelburg@hotmail.com>
from .. import parse_timestamp NOTE: An API Key is always required to use TriMet's API. Learn more here: https://developer.trimet.org/why_an_appid.shtml, and acquire one here: https://developer.trimet.org/appid/registration/
"""
from .. import parse_timestamp # ? this creates an error with pylint, ignore this.
import json import json
import requests import requests
@ -57,7 +62,8 @@ class TriMetVehicle:
self, api: TriMetAPI, vehicle_id: int, api_verify: bool = True self, api: TriMetAPI, vehicle_id: int, api_verify: bool = True
) -> ( ) -> (
bool bool
): # this is basically a glorified wrapper for load_from_json() but very lazy. also, api_verify can skip checking the api key, incase it was checked before. ): # this is basically a glorified wrapper for load_from_json() but very lazy. also,
# *api_verify can skip checking the api key, incase it was checked before.
if not api.verify() and not api_verify: if not api.verify() and not api_verify:
raise RuntimeError( raise RuntimeError(
"A valid API Key is required to use Trimet's online services." "A valid API Key is required to use Trimet's online services."
@ -72,7 +78,7 @@ class TriMetVehicle:
def load_from_json( def load_from_json(
self, object self, object
) -> bool: # **INTERNAL USAGE ONLY!!! DO NOT CALL OTHERWISE!!!** ) -> bool: # ! INTERNAL USAGE ONLY!!! DO NOT CALL OTHERWISE!!!
from ansiconverter import HEXtoRGB from ansiconverter import HEXtoRGB
self.import_data = object self.import_data = object
@ -109,7 +115,7 @@ class TriMetVehicle:
"A valid API Key is required to use Trimet's online services." "A valid API Key is required to use Trimet's online services."
) )
else: else:
self.load_from_id(api, self.id, False) return self.load_from_id(api, self.id, False)
def get_vehicles(api: TriMetAPI) -> dict: def get_vehicles(api: TriMetAPI) -> dict: