From c2d3f2a2b06309c078d71052da91714066086b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20Fr=C3=B6hlinghaus?= <120580045+ThorstenFroehlinghaus@users.noreply.github.com> Date: Thu, 17 Oct 2024 11:25:12 +0200 Subject: [PATCH] cantamen seat attributes fix (#172) --- x2gbfs/providers/cantamen.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/x2gbfs/providers/cantamen.py b/x2gbfs/providers/cantamen.py index 2cd5f5f..184692c 100644 --- a/x2gbfs/providers/cantamen.py +++ b/x2gbfs/providers/cantamen.py @@ -122,9 +122,15 @@ def _parse_attributes(self, attributes): if lowercasedClass.startswith('seats'): # seats are encoded differently per provider: SEATSX, seats_x seatsClass = lowercasedClass.replace('_', '') - numberOfSeats_str = seatsClass[len('seats') :] - numberOfSeats = 7 if numberOfSeats_str == '5plus2' else int(numberOfSeats_str) - self.seats[attributeId] = numberOfSeats + numberOfSeats = seatsClass[len('seats') :] + if numberOfSeats == '5plus2': + self.seats[attributeId] = 7 + elif numberOfSeats == '6bus': + self.seats[attributeId] = 6 + elif numberOfSeats.isdigit(): + self.seats[attributeId] = int(numberOfSeats) + else: + logger.info(f'Seat attribute {attribute["Class"]} is unknown and will be ignored') def _all_bookees(self) -> Generator[Dict[str, Any], None, None]: bookees = self._load_response()['Bookee']