Ass WAB/WAI SIGs and extract data from cluster spots. Closes #51

This commit is contained in:
Ian Renton
2025-10-20 11:35:46 +01:00
parent 20977e59cf
commit 86f2aed673
4 changed files with 37 additions and 21 deletions

View File

@@ -11,20 +11,22 @@ HTTP_HEADERS = {"User-Agent": SOFTWARE_NAME + ", v" + SOFTWARE_VERSION + " (oper
# Special Interest Groups # Special Interest Groups
SIGS = [ SIGS = [
SIG(name="POTA", description="Parks on the Air", icon="tree"), SIG(name="POTA", description="Parks on the Air", icon="tree", ref_regex=r"[A-Z]{2}\-\d+"),
SIG(name="SOTA", description="Summits on the Air", icon="mountain-sun"), SIG(name="SOTA", description="Summits on the Air", icon="mountain-sun", ref_regex=r"[A-Z0-9]{1,3}\/[A-Z]{2}\-\d+"),
SIG(name="WWFF", description="World Wide Flora & Fauna", icon="seedling"), SIG(name="WWFF", description="World Wide Flora & Fauna", icon="seedling", ref_regex=r"[A-Z0-9]{1,3}FF\-\d+"),
SIG(name="GMA", description="Global Mountain Activity", icon="person-hiking"), SIG(name="GMA", description="Global Mountain Activity", icon="person-hiking", ref_regex=r"[A-Z0-9]{1,3}\/[A-Z]{2}\-\d+"),
SIG(name="WWBOTA", description="Worldwide Bunkers on the Air", icon="radiation"), SIG(name="WWBOTA", description="Worldwide Bunkers on the Air", icon="radiation", ref_regex=r"B\/[A-Z0-9]{1,3}\-\d+"),
SIG(name="HEMA", description="HuMPs Excluding Marilyns Award", icon="mound"), SIG(name="HEMA", description="HuMPs Excluding Marilyns Award", icon="mound", ref_regex=r"[A-Z0-9]{1,3}\/[A-Z]{3}\-\d+"),
SIG(name="IOTA", description="Islands on the Air", icon="umbrella-beach"), SIG(name="IOTA", description="Islands on the Air", icon="umbrella-beach", ref_regex=r"[A-Z]{2}\-\d+"),
SIG(name="MOTA", description="Mills on the Air", icon="fan"), SIG(name="MOTA", description="Mills on the Air", icon="fan", ref_regex=r"X\d{4-6}"),
SIG(name="ARLHS", description="Amateur Radio Lighthouse Society", icon="tower-observation"), SIG(name="ARLHS", description="Amateur Radio Lighthouse Society", icon="tower-observation", ref_regex=r"[A-Z]{3}\-\d+"),
SIG(name="ILLW", description="International Lighthouse & Lightship Weekend", icon="tower-observation"), SIG(name="ILLW", description="International Lighthouse & Lightship Weekend", icon="tower-observation", ref_regex=r"[A-Z]{2}\d{4}"),
SIG(name="SIOTA", description="Silos on the Air", icon="wheat-awn"), SIG(name="SIOTA", description="Silos on the Air", icon="wheat-awn", ref_regex=r"[A-Z]{2}\-[A-Z]{3}\d"),
SIG(name="WCA", description="World Castles Award", icon="chess-rook"), SIG(name="WCA", description="World Castles Award", icon="chess-rook", ref_regex=r"[A-Z0-9]{1,3}\-\d+"),
SIG(name="ZLOTA", description="New Zealand on the Air", icon="kiwi-bird"), SIG(name="ZLOTA", description="New Zealand on the Air", icon="kiwi-bird", ref_regex=r"ZL[A-Z]/[A-Z]{2}\-\d+"),
SIG(name="KRMNPA", description="Keith Roget Memorial National Parks Award", icon="earth-oceania") SIG(name="KRMNPA", description="Keith Roget Memorial National Parks Award", icon="earth-oceania", ref_regex=r""),
SIG(name="WAB", description="Worked All Britain", icon="table-cells-large", ref_regex=r"[A-Z]{2}[0-9]{2}"),
SIG(name="WAI", description="Worked All Ireland", icon="table-cells-large", ref_regex=r"[A-Z][0-9]{2}")
] ]
# Modes. Note "DIGI" and "DIGITAL" are also supported but are normalised into "DATA". # Modes. Note "DIGI" and "DIGITAL" are also supported but are normalised into "DATA".

View File

@@ -7,8 +7,15 @@ def get_icon_for_sig(sig):
return s.icon return s.icon
return "circle-question" return "circle-question"
# Utility function to get the regex string for a SIG reference for a named SIG. If no match is found, None will be returned.
def get_ref_regex_for_sig(sig):
for s in SIGS:
if s.name == sig:
return s.ref_regex
return None
# Regex matching any SIG # Regex matching any SIG
ANY_SIG_REGEX = r"(" + r"|".join(list(map(lambda p: p.name, SIGS))) + r")" ANY_SIG_REGEX = r"(" + r"|".join(list(map(lambda p: p.name, SIGS))) + r")"
# Regex matching any SIG reference # Regex matching any SIG reference
ANY_SIG_REF_REGEX = r"[\w\/]+\-\d+" ANY_XOTA_SIG_REF_REGEX = r"[\w\/]+\-\d+"

View File

@@ -9,4 +9,6 @@ class SIG:
description: str description: str
# Icon to use for it, from the Font Awesome set. This is fairly opinionated but is here to help the Spothole web UI # Icon to use for it, from the Font Awesome set. This is fairly opinionated but is here to help the Spothole web UI
# and Field Spotter. Does not include the "fa-" prefix. # and Field Spotter. Does not include the "fa-" prefix.
icon: str icon: str
# Regex matcher for references, e.g. for POTA r"[A-Z]{2}\-\d+".
ref_regex: str

View File

@@ -8,7 +8,7 @@ import pytz
import telnetlib3 import telnetlib3
from core.constants import SIGS from core.constants import SIGS
from core.utils import ANY_SIG_REGEX, ANY_SIG_REF_REGEX, get_icon_for_sig from core.utils import ANY_SIG_REGEX, ANY_XOTA_SIG_REF_REGEX, get_icon_for_sig, get_ref_regex_for_sig
from data.spot import Spot from data.spot import Spot
from core.config import SERVER_OWNER_CALLSIGN from core.config import SERVER_OWNER_CALLSIGN
from spotproviders.spot_provider import SpotProvider from spotproviders.spot_provider import SpotProvider
@@ -78,14 +78,19 @@ class DXCluster(SpotProvider):
time=spot_datetime.timestamp()) time=spot_datetime.timestamp())
# See if the comment looks like it contains a SIG (and optionally SIG reference). Currently, # See if the comment looks like it contains a SIG (and optionally SIG reference). Currently,
# only one sig ref is supported. # only one sig ref is supported. Note that this code is specifically in the DX Cluster class and
# not in the general "spot" infer_missing() method. Because we only support one SIG per spot
# at the moment (see issue #54), we don't want to risk e.g. a POTA spot with comment "WWFF GFF-0001"
# being converted into a WWFF spot.
sig_match = re.search(r"(^|\W)" + ANY_SIG_REGEX + r"($|\W)", spot.comment, re.IGNORECASE) sig_match = re.search(r"(^|\W)" + ANY_SIG_REGEX + r"($|\W)", spot.comment, re.IGNORECASE)
if sig_match: if sig_match:
spot.sig = sig_match.group(2).upper() spot.sig = sig_match.group(2).upper()
spot.icon = get_icon_for_sig(spot.sig) spot.icon = get_icon_for_sig(spot.sig)
sig_ref_match = re.search(r"(^|\W)" + spot.sig + r"($|\W)(" + ANY_SIG_REF_REGEX + r")($|\W)", spot.comment, re.IGNORECASE) ref_regex = get_ref_regex_for_sig(spot.sig)
if sig_ref_match: if ref_regex:
spot.sig_refs = [sig_ref_match.group(3).upper()] sig_ref_match = re.search(r"(^|\W)" + spot.sig + r"($|\W)(" + ref_regex + r")($|\W)", spot.comment, re.IGNORECASE)
if sig_ref_match:
spot.sig_refs = [sig_ref_match.group(3).upper()]
# Add to our list # Add to our list
self.submit(spot) self.submit(spot)