diff --git a/src/pyrmv/classes/client.py b/src/pyrmv/classes/client.py index d2b0889..51400ff 100644 --- a/src/pyrmv/classes/client.py +++ b/src/pyrmv/classes/client.py @@ -150,7 +150,7 @@ class Client: boardType=board_type.code, ) - find_exception(board_raw) + find_exception(board_raw.copy()) return BoardArrival( board_raw, @@ -219,7 +219,7 @@ class Client: boardType=board_type.code, ) - find_exception(board_raw) + find_exception(board_raw.copy()) return BoardDeparture( board_raw, @@ -343,7 +343,7 @@ class Client: minprio=priority_min, ) - find_exception(messages_raw) + find_exception(messages_raw.copy()) if "Message" in messages_raw: messages.extend(Message(message) for message in messages_raw["Message"]) @@ -402,7 +402,7 @@ class Client: toIdx=to_index, ) - find_exception(journey_raw) + find_exception(journey_raw.copy()) return Journey(journey_raw) @@ -481,7 +481,7 @@ class Client: locationSelectionMode=selection_mode, # type: ignore ) - find_exception(stops_raw) + find_exception(stops_raw.copy()) if "stopLocationOrCoordLocation" in stops_raw: for stop in stops_raw["stopLocationOrCoordLocation"]: @@ -536,7 +536,7 @@ class Client: accessId=self.access_id, inputString=query, lang=lang.code, maxNo=1 ) - find_exception(stops_raw) + find_exception(stops_raw.copy()) if len(stops_raw["stopLocationOrCoordLocation"]) <= 0: return None @@ -642,7 +642,7 @@ class Client: filterMode=filter_mode.code, ) - find_exception(stops_raw) + find_exception(stops_raw.copy()) if "stopLocationOrCoordLocation" in stops_raw: for stop in stops_raw["stopLocationOrCoordLocation"]: @@ -833,7 +833,7 @@ class Client: withFreq=frequency, ) - find_exception(trips_raw) + find_exception(trips_raw.copy()) if "Trip" in trips_raw: trips.extend(Trip(trip) for trip in trips_raw["Trip"]) @@ -913,7 +913,7 @@ class Client: trafficMessages=messages, ) - find_exception(trips_raw) + find_exception(trips_raw.copy()) if "Trip" in trips_raw: trips.extend(Trip(trip) for trip in trips_raw["Trip"]) diff --git a/src/pyrmv/classes/message.py b/src/pyrmv/classes/message.py index e7eaa2c..7063e0f 100644 --- a/src/pyrmv/classes/message.py +++ b/src/pyrmv/classes/message.py @@ -59,9 +59,9 @@ class Message: self.channels.extend(Channel(channel) for channel in data["channel"]) self.id: str = data["id"] self.active: bool = data["act"] - self.head: str = data["head"] - self.lead: str = data["lead"] - self.text: str = data["text"] + self.head: str = "" if "head" not in data else data["head"] + self.lead: str = "" if "lead" not in data else data["lead"] + self.text: str = "" if "text" not in data else data["text"] self.company: Union[str, None] = data.get("company") self.category: Union[str, None] = data.get("category") self.priority: Union[int, None] = data.get("priority") diff --git a/src/pyrmv/classes/trip.py b/src/pyrmv/classes/trip.py index dd41494..e62c6dc 100644 --- a/src/pyrmv/classes/trip.py +++ b/src/pyrmv/classes/trip.py @@ -19,8 +19,10 @@ class Trip: self.index: int = data["idx"] self.id: str = data["tripId"] self.ctx_recon: str = data["ctxRecon"] - self.duration: Union[Duration, timedelta] = parse_duration(data["duration"]) - self.real_time_duration: Union[Duration, timedelta] = ( + self.duration: Union[Duration, timedelta, None] = ( + None if "duration" not in data else parse_duration(data["duration"]) + ) + self.real_time_duration: Union[Duration, timedelta, None] = ( None if "rtDuration" not in data else parse_duration(data["rtDuration"]) ) self.checksum: str = data["checksum"] diff --git a/src/pyrmv/raw/board_arrival.py b/src/pyrmv/raw/board_arrival.py index 1e34527..b6674ec 100644 --- a/src/pyrmv/raw/board_arrival.py +++ b/src/pyrmv/raw/board_arrival.py @@ -64,7 +64,7 @@ def board_arrival( payload = {} headers = {"Accept": "application/json"} if json else {"Accept": "application/xml"} - for var, val in locals().items(): + for var, val in locals().copy().items(): if str(var) == "date": if val != None: if isinstance(val, datetime): diff --git a/src/pyrmv/raw/board_departure.py b/src/pyrmv/raw/board_departure.py index e3cef29..dafe1fc 100644 --- a/src/pyrmv/raw/board_departure.py +++ b/src/pyrmv/raw/board_departure.py @@ -65,7 +65,7 @@ def board_departure( payload = {} headers = {"Accept": "application/json"} if json else {"Accept": "application/xml"} - for var, val in locals().items(): + for var, val in locals().copy().items(): if str(var) == "date": if val != None: if isinstance(val, datetime): diff --git a/src/pyrmv/raw/him_search.py b/src/pyrmv/raw/him_search.py index bd6a2c3..535a8e6 100644 --- a/src/pyrmv/raw/him_search.py +++ b/src/pyrmv/raw/him_search.py @@ -97,7 +97,7 @@ def him_search( payload = {} headers = {"Accept": "application/json"} if json else {"Accept": "application/xml"} - for var, val in locals().items(): + for var, val in locals().copy().items(): if str(var) in {"dateB", "dateE"}: if val != None: if isinstance(val, datetime): diff --git a/src/pyrmv/raw/journey_detail.py b/src/pyrmv/raw/journey_detail.py index 81235c2..39236d8 100644 --- a/src/pyrmv/raw/journey_detail.py +++ b/src/pyrmv/raw/journey_detail.py @@ -55,7 +55,7 @@ def journey_detail( payload = {} headers = {"Accept": "application/json"} if json else {"Accept": "application/xml"} - for var, val in locals().items(): + for var, val in locals().copy().items(): if str(var) == "rtMode": if val != None: payload["rtMode"] = val.upper() diff --git a/src/pyrmv/raw/stop_by_coords.py b/src/pyrmv/raw/stop_by_coords.py index b8c7f05..b4fbdf4 100644 --- a/src/pyrmv/raw/stop_by_coords.py +++ b/src/pyrmv/raw/stop_by_coords.py @@ -54,7 +54,7 @@ def stop_by_coords( payload = {} headers = {"Accept": "application/json"} if json else {"Accept": "application/xml"} - for var, val in locals().items(): + for var, val in locals().copy().items(): if str(var) == "stopType": if val != None: payload["type"] = val.upper() diff --git a/src/pyrmv/raw/stop_by_name.py b/src/pyrmv/raw/stop_by_name.py index 5355a0b..5ac372c 100644 --- a/src/pyrmv/raw/stop_by_name.py +++ b/src/pyrmv/raw/stop_by_name.py @@ -65,7 +65,7 @@ def stop_by_name( payload = {} headers = {"Accept": "application/json"} if json else {"Accept": "application/xml"} - for var, val in locals().items(): + for var, val in locals().copy().items(): if str(var) == "inputString": if val != None: payload["input"] = val diff --git a/src/pyrmv/raw/trip_find.py b/src/pyrmv/raw/trip_find.py index 8465074..887b2cd 100644 --- a/src/pyrmv/raw/trip_find.py +++ b/src/pyrmv/raw/trip_find.py @@ -201,7 +201,7 @@ def trip_find( payload = {} headers = {"Accept": "application/json"} if json else {"Accept": "application/xml"} - for var, val in locals().items(): + for var, val in locals().copy().items(): if str(var) == "date": if val != None: if isinstance(val, datetime): diff --git a/src/pyrmv/raw/trip_recon.py b/src/pyrmv/raw/trip_recon.py index e916e1e..ccb0941 100644 --- a/src/pyrmv/raw/trip_recon.py +++ b/src/pyrmv/raw/trip_recon.py @@ -87,7 +87,7 @@ def trip_recon( payload = {} headers = {"Accept": "application/json"} if json else {"Accept": "application/xml"} - for var, val in locals().items(): + for var, val in locals().copy().items(): if str(var) == "date": if val != None: if isinstance(val, datetime):