Skip to content

Commit

Permalink
style: black
Browse files Browse the repository at this point in the history
  • Loading branch information
2mal3 committed Jan 13, 2024
1 parent 90a314e commit 44fca21
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
10 changes: 6 additions & 4 deletions verspaetungsorakel/bahn.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from datetime import date, datetime
from os import getenv

from deutsche_bahn_api.api_authentication import ApiAuthentication
from deutsche_bahn_api.station_helper import StationHelper
from deutsche_bahn_api.timetable_helper import TimetableHelper
from deutsche_bahn_api.train import Train
from deutsche_bahn_api.train_changes import TrainChanges
from os import getenv
from datetime import date, datetime
from dotenv import load_dotenv
from pony.orm import db_session, delete, ObjectNotFound
from pony.orm import db_session

from verspaetungsorakel.database import Stop, Train, Trip, Station

Expand Down Expand Up @@ -111,7 +112,8 @@ def get_delays():
if db_stop.arrival and new_arrival:
db_stop.arrival_delay = int(round((new_arrival - db_stop.arrival).total_seconds() / 60, 0))
if db_stop.departure and new_departure:
db_stop.departure_delay = int(round((new_departure - db_stop.departure).total_seconds() / 60, 0))
db_stop.departure_delay = int(
round((new_departure - db_stop.departure).total_seconds() / 60, 0))


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions verspaetungsorakel/database.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sqlite3
from datetime import date, datetime
from pony.orm import *
from pathlib import Path
import os

from pony.orm import *

Path("database").mkdir(parents=True, exist_ok=True)

Expand Down
14 changes: 8 additions & 6 deletions verspaetungsorakel/main.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from contextlib import asynccontextmanager
from datetime import date, timedelta

from apscheduler.schedulers.asyncio import AsyncIOScheduler
from fastapi import FastAPI, Request, HTTPException
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from pony.orm import db_session, select, desc
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from slowapi import Limiter, _rate_limit_exceeded_handler
from slowapi.util import get_remote_address
from slowapi.errors import RateLimitExceeded
from datetime import date, timedelta
from contextlib import asynccontextmanager
from slowapi.util import get_remote_address

from verspaetungsorakel.database import Station, Train, Stop
from verspaetungsorakel.bahn import write_timetables_to_database, get_delays, write_stations_to_database
from verspaetungsorakel.database import Station, Train, Stop

VERSION = "0.2.8"

Expand Down Expand Up @@ -63,7 +64,8 @@ def index(request: Request, station: str = None, train: str = None):
if not db_station:
raise HTTPException(status_code=404, detail="Station not found")

db_stop = Stop.select(lambda s: s.station == db_station and s.trip.train == db_train).order_by(lambda s: desc(s.trip.date)).first()
db_stop = Stop.select(lambda s: s.station == db_station and s.trip.train == db_train).order_by(
lambda s: desc(s.trip.date)).first()
if not db_stop:
return templates.TemplateResponse("index.html", {
"request": request,
Expand Down

0 comments on commit 44fca21

Please sign in to comment.