Support KRMNPA and SANPCPA lookup via VKFF references. Closes #61

This commit is contained in:
Ian Renton
2026-08-01 09:23:35 +01:00
parent ed7f13f079
commit 01dc52f9bf
2 changed files with 27 additions and 11 deletions
+2 -1
View File
@@ -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="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="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="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="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="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}"), SIG(name="Tiles", comment_names=[], description="Tiles on the Air", ref_regex=r"[A-Za-z]{2}[0-9]{2}[A-Za-z]{2}"),
+23 -8
View File
@@ -40,19 +40,30 @@ def populate_sig_ref_info(sig_ref):
sig = sig_ref.sig sig = sig_ref.sig
ref_id = sig_ref.id 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 try:
# add leading zeros. ### 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": if sig.upper() == "DME":
ref_id = ref_id.zfill(5) ref_id = ref_id.zfill(5)
try: # KRMNPA & SANPCPA fudge. These don't have their own reference system, they just use VKFF references, so pretend
# If the SIG is HEMA or KRMNPA, we have no current lookup for this so just skip it. # 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": if sig.upper() == "HEMA" or sig.upper() == "KRMNPA":
return sig_ref 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 # 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 # calculate all the information we are going to get directly.
elif sig.upper() == "TILES": if sig.upper() == "TILES":
# Tiles on the Air just uses Maidenhead 6-digit squares, so ID, Name and Grid are all the same # Tiles on the Air just uses Maidenhead 6-digit squares, so ID, Name and Grid are all the same
if not sig_ref.name: if not sig_ref.name:
sig_ref.name = sig_ref.id 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.name = sig_ref.id
sig_ref.url = "https://www.beachesontheair.com/beaches/" + sig_ref.name.lower().replace(" ", "-") 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 # 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. # this SIG. If so, check for the reference data and use that.
elif sig in DATA_STORE.sigrefs: elif sig in DATA_STORE.sigrefs:
key = sig + ":" + ref_id key = sig + ":" + ref_id
lookup_data = DATA_STORE.sigrefs.get(key) if key in DATA_STORE.sigrefs else None lookup_data = DATA_STORE.sigrefs.get(key) if key in DATA_STORE.sigrefs else None
if lookup_data: if lookup_data:
# Copy new sig ref data into existing object # Copy new sig ref data into existing object where data was previously missing
sig_ref.__dict__.update(lookup_data.__dict__) 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: else:
logging.warning("%s database did not contain data for ref %s", sig, ref_id) logging.warning("%s database did not contain data for ref %s", sig, ref_id)