From 7b47dab54333a99dd3963421fabb523c001a4ddf Mon Sep 17 00:00:00 2001 From: Athanasius Date: Fri, 12 Aug 2022 13:57:31 +0100 Subject: [PATCH 1/2] inara: ApproachSettlement: Only set marketID if present in event At least 'Ancient Ruins' generate an `ApproachSettlement` event without a `MarketID` in the event. Not even a key with `null` value. --- plugins/inara.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/inara.py b/plugins/inara.py index 23387c3a..b380d13a 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -669,10 +669,13 @@ def journal_entry( # noqa: C901, CCR001 to_send = { 'starsystemName': system, 'stationName': entry['Name'], - 'marketID': entry['MarketID'], 'starsystemBodyName': entry['BodyName'], 'starsystemBodyCoords': [entry['Latitude'], entry['Longitude']] } + # Not present on, e.g. Ancient Ruins + if market_id := entry.get('MarketID') is not None: + to_send['marketID'] = market_id + new_add_event('setCommanderTravelLocation', entry['timestamp'], to_send) elif event_name == 'FSDJump': From 5fa9bcd48eba09243bc758e709042944f07f2789 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sat, 13 Aug 2022 18:34:28 +0100 Subject: [PATCH 2/2] inara: Wrap the ` := ` in () so isn't a bool Because, yes, 'is not' binds more tightly than ':='. --- plugins/inara.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/inara.py b/plugins/inara.py index b380d13a..5c09ec27 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -673,7 +673,7 @@ def journal_entry( # noqa: C901, CCR001 'starsystemBodyCoords': [entry['Latitude'], entry['Longitude']] } # Not present on, e.g. Ancient Ruins - if market_id := entry.get('MarketID') is not None: + if (market_id := entry.get('MarketID')) is not None: to_send['marketID'] = market_id new_add_event('setCommanderTravelLocation', entry['timestamp'], to_send)