amarillo-core/amarillo/services/agencies.py
Csaba 66cc746937
All checks were successful
Amarillo/amarillo-gitea/amarillo-core/pipeline/head This commit looks good
Use /data for region and agency configuration
2024-04-05 14:28:51 +02:00

25 lines
736 B
Python

import json
from glob import glob
from typing import Dict
from amarillo.models.Carpool import Agency
# TODO FG HB this service should also listen to pyinotify
# because the (updated) agencies are needed in the enhancer
# as well.
class AgencyService:
def __init__(self):
self.agencies: Dict[str, Agency] = {}
for agency_file_name in glob('data/agency/*.json'):
with open(agency_file_name) as agency_file:
dict = json.load(agency_file)
agency = Agency(**dict)
agency_id = agency.id
self.agencies[agency_id] = agency
def get_agency(self, agency_id: str) -> Agency:
agency = self.agencies.get(agency_id)
return agency