Compare commits
No commits in common. "b800e064a3cd618773dbde0d771a4aa264d398e4" and "ca3ba5b6849a05eaf3866282ea9854908800e1df" have entirely different histories.
b800e064a3
...
ca3ba5b684
4 changed files with 6 additions and 14 deletions
|
@ -1 +0,0 @@
|
||||||
for developer information, check my documentation repo at https://basedwa.re/elburg/bibliotheca/src/branch/en-US/opentrans
|
|
|
@ -1,4 +1,3 @@
|
||||||
# TODO: maybe put this is a different script?
|
|
||||||
def parse_timestamp(timestamp: int, type: int):
|
def parse_timestamp(timestamp: int, type: int):
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
"""
|
# Developer home: https://developer.trimet.org/ "00BA96108889B7ED8850997D7"
|
||||||
TriMet API Wrapper
|
|
||||||
Author(s): Arris Kathery <whotookelburg@hotmail.com>
|
|
||||||
|
|
||||||
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
|
||||||
"""
|
|
||||||
|
|
||||||
from .. import parse_timestamp # ? this creates an error with pylint, ignore this.
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
|
@ -62,8 +57,7 @@ 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,
|
): # 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.
|
||||||
# *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."
|
||||||
|
@ -78,7 +72,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
|
||||||
|
@ -115,7 +109,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:
|
||||||
return self.load_from_id(api, self.id, False)
|
self.load_from_id(api, self.id, False)
|
||||||
|
|
||||||
|
|
||||||
def get_vehicles(api: TriMetAPI) -> dict:
|
def get_vehicles(api: TriMetAPI) -> dict:
|
||||||
|
|
2
test.py
2
test.py
|
@ -7,6 +7,6 @@ result=src.services.TriMet.get_vehicles(api)
|
||||||
|
|
||||||
for vm in result['vehicles']:
|
for vm in result['vehicles']:
|
||||||
print(RGBtoANSI(
|
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])}\n\tJSON: {bold(vm.import_data)}",
|
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])}",
|
||||||
foregound=vm.route_color
|
foregound=vm.route_color
|
||||||
))
|
))
|
Loading…
Reference in a new issue