From eb9f12ca4287a3f01b7a50cfe01ee0654c4a61e6 Mon Sep 17 00:00:00 2001 From: Arris Kathery Date: Sat, 11 May 2024 14:16:30 -0700 Subject: [PATCH 1/2] added note and changed test again --- src/__init__.py | 1 + test.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/__init__.py b/src/__init__.py index 1dfcee6..066fc9d 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1,3 +1,4 @@ +# TODO: maybe put this is a different script? def parse_timestamp(timestamp: int, type: int): from datetime import datetime diff --git a/test.py b/test.py index 32613c7..e06f8c0 100644 --- a/test.py +++ b/test.py @@ -7,6 +7,6 @@ result=src.services.TriMet.get_vehicles(api) for vm in result['vehicles']: print(RGBtoANSI( - text=f"this is {bold(vm.type[1])} #{bold(vm.id)}.\n\troute #{bold(vm.import_data['routeNumber'])}, next stop: {bold(vm.sign[0])}\n\tboard: {bold(vm.sign[1])}", + text=f"this is {bold(vm.type[1])} #{bold(vm.id)}.\n\troute #{bold(vm.import_data['routeNumber'])}, next stop: {bold(vm.sign[0])}\n\tboard: {bold(vm.sign[1])}\n\tJSON: {bold(vm.import_data)}", foregound=vm.route_color )) \ No newline at end of file From b800e064a3cd618773dbde0d771a4aa264d398e4 Mon Sep 17 00:00:00 2001 From: Arris Kathery Date: Sat, 11 May 2024 16:18:47 -0700 Subject: [PATCH 2/2] fixed potential error in TriMetVehicle class. added notes --- NOTES.txt | 1 + src/services/TriMet.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 NOTES.txt diff --git a/NOTES.txt b/NOTES.txt new file mode 100644 index 0000000..989b289 --- /dev/null +++ b/NOTES.txt @@ -0,0 +1 @@ +for developer information, check my documentation repo at https://basedwa.re/elburg/bibliotheca/src/branch/en-US/opentrans \ No newline at end of file diff --git a/src/services/TriMet.py b/src/services/TriMet.py index 30f5c51..2add051 100644 --- a/src/services/TriMet.py +++ b/src/services/TriMet.py @@ -1,6 +1,11 @@ -# Developer home: https://developer.trimet.org/ "00BA96108889B7ED8850997D7" +""" +TriMet API Wrapper +Author(s): Arris Kathery -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 requests @@ -57,7 +62,8 @@ class TriMetVehicle: self, api: TriMetAPI, vehicle_id: int, api_verify: bool = True ) -> ( 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: raise RuntimeError( "A valid API Key is required to use Trimet's online services." @@ -72,7 +78,7 @@ class TriMetVehicle: def load_from_json( self, object - ) -> bool: # **INTERNAL USAGE ONLY!!! DO NOT CALL OTHERWISE!!!** + ) -> bool: # ! INTERNAL USAGE ONLY!!! DO NOT CALL OTHERWISE!!! from ansiconverter import HEXtoRGB self.import_data = object @@ -109,7 +115,7 @@ class TriMetVehicle: "A valid API Key is required to use Trimet's online services." ) else: - self.load_from_id(api, self.id, False) + return self.load_from_id(api, self.id, False) def get_vehicles(api: TriMetAPI) -> dict: