2 Commits

3 changed files with 9 additions and 11 deletions

View File

@@ -38,7 +38,6 @@ from .idfm_types import (
from .ratp_types import Picto as RatpPicto
logger = getLogger(__name__)
@@ -60,7 +59,7 @@ class IdfmInterface:
)
OPERATOR_RE = re_compile(r"[^:]+:Operator::([^:]+):")
LINE_RE = re_compile(r"[^:]+:Line::([^:]+):")
LINE_RE = re_compile(r"[^:]+:Line::C([^:]+):")
def __init__(self, api_key: str, database: Database) -> None:
self._api_key = api_key

View File

@@ -199,11 +199,12 @@ async def get_next_passages(stop_id: int) -> NextPassagesSchema | None:
# re.match will return None if the given journey.LineRef.value is not valid.
try:
line_id = IdfmInterface.LINE_RE.match(journey.LineRef.value).group(1)
except AttributeError as exc:
line_id_match = IdfmInterface.LINE_RE.match(journey.LineRef.value)
line_id = int(line_id_match.group(1)) # type: ignore
except (AttributeError, TypeError, ValueError) as err:
raise HTTPException(
status_code=404, detail=f'Line "{journey.LineRef.value}" not found'
) from exc
) from err
call = journey.MonitoredCall

View File

@@ -56,10 +56,8 @@ export function BusinessDataProvider(props: { children: JSX.Element }) {
line = json;
}
else {
console.warn(`No line found for ${lineId} line id (${json}).`);
console.warn(`No line found for ${lineId} line id:`, json);
}
}
return line;
}
@@ -113,7 +111,7 @@ export function BusinessDataProvider(props: { children: JSX.Element }) {
addPassages(json.passages);
}
else {
console.warn(`No passage found for ${stopId} stop (${json}).`);
console.warn(`No passage found for ${stopId} stop:`, json);
}
}
@@ -194,7 +192,7 @@ ${linePassagesDestination.length} here... refresh all them.`);
}
}
else {
console.warn(`No stop found for '${name}' (${json}).`);
console.warn(`No stop found for '${name}' query:`, json);
}
return byIdStops;
@@ -223,7 +221,7 @@ ${linePassagesDestination.length} here... refresh all them.`);
shape = json;
}
else {
console.warn(`No shape found for ${stopId} stop (${json}).`);
console.warn(`No shape found for ${stopId} stop:`, json);
}
}
return shape;