Skip to content

Commit 450ae03

Browse files
committed
attributions.txt fix
Signed-off-by: Clemens Vasters <[email protected]>
1 parent d5cd119 commit 450ae03

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

gtfs/gtfs_rt_bridge/src/gtfs_rt_bridge/gtfs_cli.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from typing import Any, Dict, List, Tuple
1717
from datetime import datetime, timedelta, timezone
1818
from tempfile import TemporaryDirectory
19+
import uuid
1920
from zipfile import ZipFile
2021
from enum import Enum
2122
import dataclasses
@@ -303,7 +304,7 @@ def map_areas(rows: List[Dict[str, Any]]) -> List[Areas]:
303304
def map_attributions(rows: List[Dict[str, Any]]) -> List[Attributions]:
304305
"""Maps the rows from the attributions.txt file to a list of Attributions objects"""
305306
return [Attributions(
306-
attributionId=row.get("attribution_id"),
307+
attributionId=row.get("attribution_id", row.get("trip_id", uuid.uuid4().hex)),
307308
agencyId=row.get("agency_id"),
308309
routeId=row.get("route_id"),
309310
tripId=row.get("trip_id"),
@@ -815,7 +816,7 @@ async def fetch_and_process_schedule(agency_id: str, reference_producer_client:
815816
entities = map_attributions(file_contents)
816817
logger.info("Processing %s attributions entities", len(entities))
817818
for entity in entities:
818-
await reference_producer_client.send_general_transit_feed_static_attributions(agency_url, (entity.agencyId if entity.agencyId else agency_id)+"/"+entity.attributionId+"/"+entity.routeId+"/"+entity.tripId, entity, flush_producer=False)
819+
await reference_producer_client.send_general_transit_feed_static_attributions(agency_url, (entity.agencyId if entity.agencyId else agency_id)+"/"+entity.attributionId+"/"+(entity.routeId if entity.routeId else "any")+"/"+entity.tripId, entity, flush_producer=False)
819820
send_count += 1
820821
if send_count % 100 == 0:
821822
reference_producer_client.producer.flush()

0 commit comments

Comments
 (0)