mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 14:27:42 +00:00
More defensive coding
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user