ratp: Ensure InfoChannelRef is present

This commit is contained in:
nemunaire 2022-09-21 16:47:38 +02:00
parent b21112be3f
commit 42ced57be1

View File

@ -193,14 +193,14 @@ class RATPWeatherModule:
return icon return icon
for info in weather[mode][line]: for info in weather[mode][line]:
if info["InfoChannelRef"]["value"] != "Perturbation": if "InfoChannelRef" not in info or info["InfoChannelRef"]["value"] != "Perturbation":
continue continue
if "Message" not in info["Content"]: if "Message" not in info["Content"]:
continue continue
for msg in info["Content"]["Message"]: for msg in info["Content"]["Message"]:
if msg["MessageType"] != "SHORT_MESSAGE": if "MessageType" not in msg or msg["MessageType"] != "SHORT_MESSAGE":
continue continue
yield { yield {
@ -233,7 +233,8 @@ class RATPWeatherModule:
states = [] states = []
for info in weather[mode][line]: for info in weather[mode][line]:
states.append(info["InfoChannelRef"]["value"]) if "InfoChannelRef" in info:
states.append(info["InfoChannelRef"]["value"])
fill = "gray" if "Perturbation" not in states else "black" fill = "gray" if "Perturbation" not in states else "black"