Fixed rtDuration and transferCount

This commit is contained in:
Profitroll 2022-09-24 13:07:58 +02:00
parent 947e6361f6
commit 7b0f2c31ed

View File

@ -19,9 +19,18 @@ class Trip():
self.id = data["tripId"] self.id = data["tripId"]
self.ctx_recon = data["ctxRecon"] self.ctx_recon = data["ctxRecon"]
self.duration = parse_duration(data["duration"]) self.duration = parse_duration(data["duration"])
self.real_time_duration = parse_duration(data["rtDuration"])
if "rtDuration" in data:
self.real_time_duration = parse_duration(data["rtDuration"])
else:
self.real_time_duration = None
self.checksum = data["checksum"] self.checksum = data["checksum"]
self.transfer_count = data["transferCount"]
if "transferCount" in data:
self.transfer_count = data["transferCount"]
else:
self.transfer_count = 0
def __str__(self) -> str: def __str__(self) -> str:
return f"Trip from {self.origin.name} to {self.destination.name} lasting {self.duration} ({self.real_time_duration}) with {len(self.legs)} legs and {self.transfer_count} transfers" return f"Trip from {self.origin.name} to {self.destination.name} lasting {self.duration} ({self.real_time_duration}) with {len(self.legs)} legs and {self.transfer_count} transfers"