From 7b0f2c31ed92d655e93c9813608cd9f9f2cbff6e Mon Sep 17 00:00:00 2001 From: Profitroll <47523801+profitrollgame@users.noreply.github.com> Date: Sat, 24 Sep 2022 13:07:58 +0200 Subject: [PATCH] Fixed rtDuration and transferCount --- pyrmv/classes/Trip.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pyrmv/classes/Trip.py b/pyrmv/classes/Trip.py index d6eced9..cc463ab 100644 --- a/pyrmv/classes/Trip.py +++ b/pyrmv/classes/Trip.py @@ -19,9 +19,18 @@ class Trip(): self.id = data["tripId"] self.ctx_recon = data["ctxRecon"] 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.transfer_count = data["transferCount"] + + if "transferCount" in data: + self.transfer_count = data["transferCount"] + else: + self.transfer_count = 0 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" \ No newline at end of file