From 01dc52f9bfba7f119c48f5ee6055baca54487652 Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Sat, 1 Aug 2026 09:23:35 +0100 Subject: [PATCH] Support KRMNPA and SANPCPA lookup via VKFF references. Closes #61 --- core/constants.py | 3 ++- core/sig_utils.py | 35 +++++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/core/constants.py b/core/constants.py index c0d42c5..1d27e0b 100644 --- a/core/constants.py +++ b/core/constants.py @@ -26,7 +26,8 @@ SIGS = [ SIG(name="ZLOTA", comment_names=["ZLOTA"], description="New Zealand on the Air", ref_regex=r"ZL[A-Z]/[A-Z]{2}\-\d{3,4}"), SIG(name="WOTA", comment_names=["WOTA"], description="Wainwrights on the Air", ref_regex=r"[A-Z]{3}-[0-9]{2}"), SIG(name="BOTA", comment_names=[], description="Beaches on the Air"), - SIG(name="KRMNPA", comment_names=["KRMNPA"], description="Keith Roget Memorial National Parks Award"), + SIG(name="KRMNPA", comment_names=["KRMNPA"], description="Keith Roget Memorial National Parks Award", ref_regex=r"VKFF\-\d{4}"), + SIG(name="SANPCPA", comment_names=["SANPCPA"], description="South Australian National Parks and Conservation Parks Award", ref_regex=r"VKFF\-\d{4}"), SIG(name="LLOTA", comment_names=["LLOTA"], description="Lagos y Lagunas on the Air", ref_regex=r"LL[A-Z]{2}\-\d{4}"), SIG(name="Towers", comment_names=["TOTA"], description="Towers on the Air", ref_regex=r"[A-Z]{2,3}R\-\d{4}"), SIG(name="Tiles", comment_names=[], description="Tiles on the Air", ref_regex=r"[A-Za-z]{2}[0-9]{2}[A-Za-z]{2}"), diff --git a/core/sig_utils.py b/core/sig_utils.py index 486f8e0..a3ee09b 100644 --- a/core/sig_utils.py +++ b/core/sig_utils.py @@ -40,19 +40,30 @@ def populate_sig_ref_info(sig_ref): sig = sig_ref.sig ref_id = sig_ref.id - # DME fudge. Our database has leading zeros padding to 5 digits which is the expected format, but not all activators - # add leading zeros. - if sig.upper() == "DME": - ref_id = ref_id.zfill(5) - try: - # If the SIG is HEMA or KRMNPA, we have no current lookup for this so just skip it. + ### FUDGES ### + # + # DME fudge. Our database has leading zeros padding to 5 digits which is the expected format, but not all + # activators add leading zeros. + if sig.upper() == "DME": + ref_id = ref_id.zfill(5) + + # KRMNPA & SANPCPA fudge. These don't have their own reference system, they just use VKFF references, so pretend + # the sig is WWFF and carry on + if sig.upper() == "KRMNPA" or sig.upper() == "SANPCPA": + sig = "WWFF" + + ### SKIPS ### + # + # If the SIG is HEMA, we have no current lookup for this so just skip the lookup here. if sig.upper() == "HEMA" or sig.upper() == "KRMNPA": return sig_ref + ### PROGRAMMATIC DATA GENERATION INSTEAD OF LOOKUPS ### + # # If the SIG is Tiles, WAB, WAI or BOTA (Beaches), we don't have anything to look up from the data store, we can - # calculate all the information we are going to get directly. So handle those cases first - elif sig.upper() == "TILES": + # calculate all the information we are going to get directly. + if sig.upper() == "TILES": # Tiles on the Air just uses Maidenhead 6-digit squares, so ID, Name and Grid are all the same if not sig_ref.name: sig_ref.name = sig_ref.id @@ -80,14 +91,18 @@ def populate_sig_ref_info(sig_ref): sig_ref.name = sig_ref.id sig_ref.url = "https://www.beachesontheair.com/beaches/" + sig_ref.name.lower().replace(" ", "-") + ### ACTUAL LOOKUP ### + # # OK, this is something we have to look up. Now check to see if our data store contains SIG ref information for # this SIG. If so, check for the reference data and use that. elif sig in DATA_STORE.sigrefs: key = sig + ":" + ref_id lookup_data = DATA_STORE.sigrefs.get(key) if key in DATA_STORE.sigrefs else None if lookup_data: - # Copy new sig ref data into existing object - sig_ref.__dict__.update(lookup_data.__dict__) + # Copy new sig ref data into existing object where data was previously missing + for key, value in lookup_data.__dict__.items(): + if value is not None and sig_ref.__dict__.get(key) is None: + sig_ref.__dict__[key] = value else: logging.warning("%s database did not contain data for ref %s", sig, ref_id)