Refactor looking up SIG reference details into a common location, taking it out of the individual spot providers. This means we can now look up references properly from Cluster spot comments, etc. Closes #74 as there is no longer any duplication of these lookups. Works towards #54 as sig_refs now specify their sig internally.

This commit is contained in:
Ian Renton
2025-11-02 15:45:19 +00:00
parent 28010a68ae
commit 286ff66721
22 changed files with 192 additions and 233 deletions

View File

@@ -34,7 +34,7 @@ class GMA(HTTPSpotProvider):
mode=source_spot["MODE"].upper() if "<>" not in source_spot["MODE"] else None,
# Filter out some weird mode strings
comment=source_spot["TEXT"],
sig_refs=[SIGRef(id=source_spot["REF"], name=source_spot["NAME"], url="https://www.cqgma.org/zinfo.php?ref=" + source_spot["REF"])],
sig_refs=[SIGRef(id=source_spot["REF"], sig="", name=source_spot["NAME"])],
time=datetime.strptime(source_spot["DATE"] + source_spot["TIME"], "%Y%m%d%H%M").replace(
tzinfo=pytz.UTC).timestamp(),
dx_latitude=float(source_spot["LAT"]) if (source_spot["LAT"] and source_spot["LAT"] != "") else None,
@@ -54,22 +54,21 @@ class GMA(HTTPSpotProvider):
if ref_info["reftype"] not in ["POTA", "WWFF"] and (ref_info["reftype"] != "Summit" or ref_info["sota"] == ""):
match ref_info["reftype"]:
case "Summit":
spot.sig = "GMA"
spot.sig_refs[0].sig = "GMA"
case "IOTA Island":
spot.sig = "IOTA"
spot.sig_refs[0].sig = "IOTA"
case "Lighthouse (ILLW)":
spot.sig = "ILLW"
spot.sig_refs[0].sig = "ILLW"
case "Lighthouse (ARLHS)":
spot.sig = "ARLHS"
spot.sig_refs[0].sig = "ARLHS"
case "Castle":
spot.sig = "WCA"
spot.sig_refs[0].sig = "WCA"
case "Mill":
spot.sig = "MOTA"
spot.sig_refs[0].sig = "MOTA"
case _:
logging.warn("GMA spot found with ref type " + ref_info[
"reftype"] + ", developer needs to add support for this!")
spot.sig = ref_info["reftype"]
spot.icon = get_icon_for_sig(spot.sig)
spot.sig_refs[0].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
# that for us.