More defensive coding

This commit is contained in:
Ian Renton
2026-08-17 13:43:40 +01:00
parent 7623ae667e
commit 03164d747f
10 changed files with 27 additions and 19 deletions
+7
View File
@@ -129,6 +129,13 @@ class QRZ(APIQueryCallsignDataProvider):
def qrz_response_to_callsign(callsign, data):
"""Convert the "Callsign" block in QRZ's API response to our own Callsign object."""
# I have encountered a user passing multiple callsigns to the QRZ lookup function in a way that QRZ actually
# does handle, and returns a list of callsign data. If we encounter that, just take the first one, as our own
# functions can't deal with multiple calls this way.
if isinstance(data, list):
data = data[0]
callsign = data["call"]
# Get a name
name = None
if "name_fmt" in data:
+5 -4
View File
@@ -61,10 +61,11 @@ class WOTA(HTTPSpotProvider):
try:
desc_split = source_spot.description.split(". ")
freq_mode = desc_split[0].replace("Frequencies/modes:", "").strip()
freq_mode_split = re.split(r"[\-\s]+", freq_mode)
freq_hz = float(freq_mode_split[0].replace("'", ".")) * 1000000
if len(freq_mode_split) > 1:
mode = freq_mode_split[1].upper()
if freq_mode and freq_mode != "-":
freq_mode_split = re.split(r"[\-\s]+", freq_mode)
freq_hz = float(freq_mode_split[0].replace("'", ".")) * 1000000
if len(freq_mode_split) > 1:
mode = freq_mode_split[1].upper()
if len(desc_split) > 1:
comment = desc_split[1].strip()