mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-12-16 09:03:39 +00:00
Defensive coding
This commit is contained in:
@@ -41,40 +41,42 @@ class GMA(HTTPSpotProvider):
|
|||||||
dx_longitude=float(source_spot["LON"]) if (source_spot["LON"] and source_spot["LON"] != "") else None)
|
dx_longitude=float(source_spot["LON"]) if (source_spot["LON"] and source_spot["LON"] != "") else None)
|
||||||
|
|
||||||
# GMA doesn't give what programme (SIG) the reference is for until we separately look it up.
|
# GMA doesn't give what programme (SIG) the reference is for until we separately look it up.
|
||||||
ref_response = SEMI_STATIC_URL_DATA_CACHE.get(self.REF_INFO_URL_ROOT + source_spot["REF"],
|
if "REF" in source_spot:
|
||||||
headers=HTTP_HEADERS)
|
ref_response = SEMI_STATIC_URL_DATA_CACHE.get(self.REF_INFO_URL_ROOT + source_spot["REF"],
|
||||||
# Sometimes this is blank, so handle that
|
headers=HTTP_HEADERS)
|
||||||
if ref_response.text is not None and ref_response.text != "":
|
# Sometimes this is blank, so handle that
|
||||||
ref_info = ref_response.json()
|
if ref_response.text is not None and ref_response.text != "":
|
||||||
# If this is POTA, SOTA or WWFF data we already have it through other means, so ignore. POTA and WWFF
|
ref_info = ref_response.json()
|
||||||
# spots come through with reftype=POTA or reftype=WWFF. SOTA is harder to figure out because both SOTA
|
# If this is POTA, SOTA or WWFF data we already have it through other means, so ignore. POTA and WWFF
|
||||||
# and GMA summits come through with reftype=Summit, so we must check for the presence of a "sota" entry
|
# spots come through with reftype=POTA or reftype=WWFF. SOTA is harder to figure out because both SOTA
|
||||||
# to determine if it's a SOTA summit.
|
# and GMA summits come through with reftype=Summit, so we must check for the presence of a "sota" entry
|
||||||
if "reftype" in ref_info and ref_info["reftype"] not in ["POTA", "WWFF"] and (ref_info["reftype"] != "Summit" or ref_info["sota"] == ""):
|
# to determine if it's a SOTA summit.
|
||||||
match ref_info["reftype"]:
|
if "reftype" in ref_info and ref_info["reftype"] not in ["POTA", "WWFF"] and (
|
||||||
case "Summit":
|
ref_info["reftype"] != "Summit" or ref_info["sota"] == ""):
|
||||||
spot.sig_refs[0].sig = "GMA"
|
match ref_info["reftype"]:
|
||||||
spot.sig = "GMA"
|
case "Summit":
|
||||||
case "IOTA Island":
|
spot.sig_refs[0].sig = "GMA"
|
||||||
spot.sig_refs[0].sig = "IOTA"
|
spot.sig = "GMA"
|
||||||
spot.sig = "IOTA"
|
case "IOTA Island":
|
||||||
case "Lighthouse (ILLW)":
|
spot.sig_refs[0].sig = "IOTA"
|
||||||
spot.sig_refs[0].sig = "ILLW"
|
spot.sig = "IOTA"
|
||||||
spot.sig = "ILLW"
|
case "Lighthouse (ILLW)":
|
||||||
case "Lighthouse (ARLHS)":
|
spot.sig_refs[0].sig = "ILLW"
|
||||||
spot.sig_refs[0].sig = "ARLHS"
|
spot.sig = "ILLW"
|
||||||
spot.sig = "ARLHS"
|
case "Lighthouse (ARLHS)":
|
||||||
case "Castle":
|
spot.sig_refs[0].sig = "ARLHS"
|
||||||
spot.sig_refs[0].sig = "WCA"
|
spot.sig = "ARLHS"
|
||||||
spot.sig = "WCA"
|
case "Castle":
|
||||||
case "Mill":
|
spot.sig_refs[0].sig = "WCA"
|
||||||
spot.sig_refs[0].sig = "MOTA"
|
spot.sig = "WCA"
|
||||||
spot.sig = "MOTA"
|
case "Mill":
|
||||||
case _:
|
spot.sig_refs[0].sig = "MOTA"
|
||||||
logging.warn("GMA spot found with ref type " + ref_info[
|
spot.sig = "MOTA"
|
||||||
"reftype"] + ", developer needs to add support for this!")
|
case _:
|
||||||
spot.sig_refs[0].sig = ref_info["reftype"]
|
logging.warn("GMA spot found with ref type " + ref_info[
|
||||||
spot.sig = ref_info["reftype"]
|
"reftype"] + ", developer needs to add support for this!")
|
||||||
|
spot.sig_refs[0].sig = ref_info["reftype"]
|
||||||
|
spot.sig = ref_info["reftype"]
|
||||||
|
|
||||||
# Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other code will do
|
# Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other code will do
|
||||||
# that for us.
|
# that for us.
|
||||||
|
|||||||
Reference in New Issue
Block a user