Cleaned up unused code
This commit is contained in:
parent
3d1764df57
commit
c353111e60
|
|
@ -16,7 +16,7 @@ import os
|
||||||
from watchdog.observers import Observer
|
from watchdog.observers import Observer
|
||||||
from watchdog.events import FileSystemEventHandler
|
from watchdog.events import FileSystemEventHandler
|
||||||
from .models.Carpool import Carpool, Region
|
from .models.Carpool import Carpool, Region
|
||||||
from .router import _assert_region_exists
|
from .utils import _assert_region_exists
|
||||||
from amarillo_stops import stops
|
from amarillo_stops import stops
|
||||||
from .services.trips import TripStore, Trip
|
from .services.trips import TripStore, Trip
|
||||||
from .services.carpools import CarpoolService
|
from .services.carpools import CarpoolService
|
||||||
|
|
@ -212,27 +212,6 @@ app = FastAPI(title="Amarillo GTFS Generator",
|
||||||
|
|
||||||
init()
|
init()
|
||||||
|
|
||||||
# @app.post("/",
|
|
||||||
# operation_id="enhancecarpool",
|
|
||||||
# summary="Add a new or update existing carpool",
|
|
||||||
# description="Carpool object to be enhanced",
|
|
||||||
# responses={
|
|
||||||
# status.HTTP_404_NOT_FOUND: {
|
|
||||||
# "description": "Agency does not exist"},
|
|
||||||
|
|
||||||
# })
|
|
||||||
#TODO: add examples
|
|
||||||
# async def post_carpool(carpool: Carpool = Body(...)):
|
|
||||||
|
|
||||||
# logger.info(f"POST trip {carpool.agency}:{carpool.id}.")
|
|
||||||
|
|
||||||
# trips_store: TripStore = container['trips_store']
|
|
||||||
# trip = trips_store._load_as_trip(carpool)
|
|
||||||
|
|
||||||
#TODO: carpool deleted endpoint
|
|
||||||
|
|
||||||
#TODO: gtfs, gtfs-rt endpoints
|
|
||||||
|
|
||||||
@app.get("/region/{region_id}/gtfs",
|
@app.get("/region/{region_id}/gtfs",
|
||||||
summary="Return GTFS Feed for this region",
|
summary="Return GTFS Feed for this region",
|
||||||
response_description="GTFS-Feed (zip-file)",
|
response_description="GTFS-Feed (zip-file)",
|
||||||
|
|
@ -267,11 +246,8 @@ async def get_file(region_id: str, format: str = 'protobuf'):
|
||||||
message = "Specified format is not supported, i.e. neither protobuf nor json."
|
message = "Specified format is not supported, i.e. neither protobuf nor json."
|
||||||
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=message)
|
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=message)
|
||||||
|
|
||||||
#TODO: sync endpoint that calls midnight
|
|
||||||
|
|
||||||
@app.post("/sync",
|
@app.post("/sync",
|
||||||
operation_id="sync")
|
operation_id="sync")
|
||||||
#TODO: add examples
|
|
||||||
async def post_sync():
|
async def post_sync():
|
||||||
|
|
||||||
logger.info(f"Sync")
|
logger.info(f"Sync")
|
||||||
|
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
import logging
|
|
||||||
|
|
||||||
from fastapi import APIRouter, HTTPException, status, Depends
|
|
||||||
|
|
||||||
from amarillo.models.Carpool import Region
|
|
||||||
from amarillo.services.regions import RegionService
|
|
||||||
# from amarillo.services.oauth2 import get_current_user, verify_permission
|
|
||||||
# from amarillo.models.User import User
|
|
||||||
from amarillo.utils.container import container
|
|
||||||
from fastapi.responses import FileResponse
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
router = APIRouter()
|
|
||||||
|
|
||||||
# @router.post("/export")
|
|
||||||
# async def trigger_export(requesting_user: User = Depends(get_current_user)):
|
|
||||||
# verify_permission("generate-gtfs", requesting_user)
|
|
||||||
# #import is here to avoid circular import
|
|
||||||
# from amarillo.plugins.gtfs_export.gtfs_generator import generate_gtfs
|
|
||||||
# generate_gtfs()
|
|
||||||
|
|
||||||
#TODO: move to amarillo/utils?
|
|
||||||
def _assert_region_exists(region_id: str) -> Region:
|
|
||||||
regions: RegionService = container['regions']
|
|
||||||
region = regions.get_region(region_id)
|
|
||||||
region_exists = region is not None
|
|
||||||
|
|
||||||
if not region_exists:
|
|
||||||
message = f"Region with id {region_id} does not exist."
|
|
||||||
logger.error(message)
|
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=message)
|
|
||||||
|
|
||||||
return region
|
|
||||||
|
|
||||||
|
|
||||||
# @router.get("/region/{region_id}/gtfs",
|
|
||||||
# summary="Return GTFS Feed for this region",
|
|
||||||
# response_description="GTFS-Feed (zip-file)",
|
|
||||||
# response_class=FileResponse,
|
|
||||||
# responses={
|
|
||||||
# status.HTTP_404_NOT_FOUND: {"description": "Region not found"},
|
|
||||||
# }
|
|
||||||
# )
|
|
||||||
# async def get_file(region_id: str, requesting_user: User = Depends(get_current_user)):
|
|
||||||
# verify_permission("gtfs", requesting_user)
|
|
||||||
# _assert_region_exists(region_id)
|
|
||||||
# return FileResponse(f'data/gtfs/amarillo.{region_id}.gtfs.zip')
|
|
||||||
|
|
||||||
# @router.get("/region/{region_id}/gtfs-rt",
|
|
||||||
# summary="Return GTFS-RT Feed for this region",
|
|
||||||
# response_description="GTFS-RT-Feed",
|
|
||||||
# response_class=FileResponse,
|
|
||||||
# responses={
|
|
||||||
# status.HTTP_404_NOT_FOUND: {"description": "Region not found"},
|
|
||||||
# status.HTTP_400_BAD_REQUEST: {"description": "Bad request, e.g. because format is not supported, i.e. neither protobuf nor json."}
|
|
||||||
# }
|
|
||||||
# )
|
|
||||||
# async def get_file(region_id: str, format: str = 'protobuf', requesting_user: User = Depends(get_current_user)):
|
|
||||||
# verify_permission("gtfs", requesting_user)
|
|
||||||
# _assert_region_exists(region_id)
|
|
||||||
# if format == 'json':
|
|
||||||
# return FileResponse(f'data/gtfs/amarillo.{region_id}.gtfsrt.json')
|
|
||||||
# elif format == 'protobuf':
|
|
||||||
# return FileResponse(f'data/gtfs/amarillo.{region_id}.gtfsrt.pbf')
|
|
||||||
# else:
|
|
||||||
# message = "Specified format is not supported, i.e. neither protobuf nor json."
|
|
||||||
# raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=message)
|
|
||||||
|
|
@ -15,6 +15,7 @@ import logging
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
#TODO: remove unused functions from Trip class
|
||||||
class Trip:
|
class Trip:
|
||||||
|
|
||||||
def __init__(self, trip_id, route_name, headsign, url, calendar, departureTime, path, agency, lastUpdated, stop_times, driver: Driver, additional_ridesharing_info: RidesharingInfo, route_color, route_text_color, bbox):
|
def __init__(self, trip_id, route_name, headsign, url, calendar, departureTime, path, agency, lastUpdated, stop_times, driver: Driver, additional_ridesharing_info: RidesharingInfo, route_color, route_text_color, bbox):
|
||||||
|
|
|
||||||
23
amarillo_gtfs_generator/utils.py
Normal file
23
amarillo_gtfs_generator/utils.py
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from fastapi import HTTPException, status
|
||||||
|
|
||||||
|
from amarillo.models.Carpool import Region
|
||||||
|
from amarillo.services.regions import RegionService
|
||||||
|
from amarillo.utils.container import container
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
#TODO: move to amarillo/utils?
|
||||||
|
def _assert_region_exists(region_id: str) -> Region:
|
||||||
|
regions: RegionService = container['regions']
|
||||||
|
region = regions.get_region(region_id)
|
||||||
|
region_exists = region is not None
|
||||||
|
|
||||||
|
if not region_exists:
|
||||||
|
message = f"Region with id {region_id} does not exist."
|
||||||
|
logger.error(message)
|
||||||
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=message)
|
||||||
|
|
||||||
|
return region
|
||||||
|
|
||||||
Loading…
Reference in a new issue