Allow some SIG refs to be picked up from comments without separate SIG name. Closes #134

This commit is contained in:
Ian Renton
2026-08-31 20:49:15 +01:00
parent e4738b2c7d
commit 892827f1f8
15 changed files with 111 additions and 49 deletions
+51 -26
View File
@@ -16,91 +16,104 @@ SIGS = [
comment_names=["POTA"],
description="Parks on the Air",
ref_regex=r"[A-Z]{2}\-\d{4,5}|K\-TEST",
icon="fa-tree"
icon="fa-tree",
refs_globally_unique=False
),
SIG(
name="SOTA",
comment_names=["SOTA"],
description="Summits on the Air",
ref_regex=r"[A-Z0-9]{1,3}\/[A-Z]{2}\-\d{3}",
icon="fa-mountain-sun"
icon="fa-mountain-sun",
refs_globally_unique=False
),
SIG(
name="WWFF",
comment_names=["WWFF"],
description="World Wide Flora & Fauna",
ref_regex=r"[A-Z0-9]{1,3}FF\-\d{4}",
icon="fa-seedling"
icon="fa-seedling",
refs_globally_unique=True
),
SIG(
name="GMA",
comment_names=["GMA"],
description="Global Mountain Activity",
ref_regex=r"[A-Z0-9]{1,3}\/[A-Z]{2}\-\d{3}",
icon="fa-person-hiking"
icon="fa-person-hiking",
refs_globally_unique=False
),
SIG(
name="WWBOTA",
comment_names=["WWBOTA", "BOTA"],
description="Worldwide Bunkers on the Air",
ref_regex=r"B\/[A-Z0-9]{1,3}\-\d{3,4}",
icon="fa-radiation"
icon="fa-radiation",
refs_globally_unique=True
),
SIG(
name="HEMA",
comment_names=["HEMA"],
description="HuMPs Excluding Marilyns Award",
ref_regex=r"[A-Z0-9]{1,3}\/[A-Z]{3}\-\d{3}",
icon="fa-mound"
icon="fa-mound",
refs_globally_unique=False
),
SIG(
name="IOTA",
comment_names=["IOTA"],
description="Islands on the Air",
ref_regex=r"[A-Z]{2}\-\d{3}",
icon="fa-book-atlas"
icon="fa-book-atlas",
refs_globally_unique=False
),
SIG(
name="GMA Islands",
comment_names=[],
description="Global Mountain Activity - Islands",
ref_regex=r"(([A-Z]{2}\-\d{3})|([A-Z0-9]{1,3}\/[A-Z]{2}\-\d{3}))",
icon="fa-person-hiking"
icon="fa-person-hiking",
refs_globally_unique=False
),
SIG(
name="ARLHS",
comment_names=["ARLHS"],
description="Amateur Radio Lighthouse Society",
ref_regex=r"[A-Z]{3}[\- ]\d{3,4}",
icon="fa-house-flood-water"
icon="fa-house-flood-water",
refs_globally_unique=False
),
SIG(
name="ILLW",
comment_names=["ILLW"],
description="International Lighthouse & Lightship Weekend",
ref_regex=r"[A-Z]{2}\d{4}",
icon="fa-house-flood-water"
icon="fa-house-flood-water",
refs_globally_unique=False
),
SIG(
name="MOTA",
comment_names=["MOTA"],
description="Mills on the Air",
ref_regex=r"X\d{4,6}",
icon="fa-fan"
icon="fa-fan",
refs_globally_unique=True
),
SIG(
name="SIOTA",
comment_names=["SIOTA"],
description="Silos on the Air",
ref_regex=r"[A-Z]{2}\-[A-Z]{3}\d",
icon="fa-wheat-awn"
icon="fa-wheat-awn",
refs_globally_unique=False
),
SIG(
name="WCA",
comment_names=["WCA"],
description="World Castles Award",
ref_regex=r"[A-Z0-9]{1,3}\-\d{5}",
icon="fa-chess-rook"
icon="fa-chess-rook",
refs_globally_unique=False
),
SIG(
name="ZLOTA",
@@ -108,7 +121,8 @@ SIGS = [
description="New Zealand on the Air",
ref_regex=r"ZL[A-Z]/[A-Z]{2}\-\d{3,4}",
icon="fa-kiwi-bird",
region_flag="🇳🇿"
region_flag="🇳🇿",
refs_globally_unique=True
),
SIG(
name="WOTA",
@@ -116,7 +130,8 @@ SIGS = [
description="Wainwrights on the Air",
ref_regex=r"[A-Z]{3}-[0-9]{2}",
icon="fa-w",
region_flag="🇬🇧"
region_flag="🇬🇧",
refs_globally_unique=False
),
SIG(name="BOTA",
comment_names=[],
@@ -144,21 +159,24 @@ SIGS = [
comment_names=["LLOTA"],
description="Lagos y Lagunas on the Air",
ref_regex=r"LL[A-Z]{2}\-\d{4}",
icon="fa-water"
icon="fa-water",
refs_globally_unique=True
),
SIG(
name="Towers",
comment_names=["TOTA"],
description="Towers on the Air",
ref_regex=r"[A-Z]{2,3}R\-\d{4}",
icon="fa-tower-observation"
icon="fa-tower-observation",
refs_globally_unique=False
),
SIG(
name="Tiles",
comment_names=[],
description="Tiles on the Air",
ref_regex=r"[A-Za-z]{2}[0-9]{2}[A-Za-z]{2}",
icon="fa-square"
icon="fa-square",
refs_globally_unique=False
),
SIG(
name="WAB",
@@ -166,7 +184,8 @@ SIGS = [
description="Worked All Britain",
ref_regex=r"[A-Z]{1,2}[0-9]{2}",
icon="fa-table-cells-large",
region_flag="🇬🇧"
region_flag="🇬🇧",
refs_globally_unique=False
),
SIG(
name="WAI",
@@ -174,7 +193,8 @@ SIGS = [
description="Worked All Ireland",
ref_regex=r"[A-Z][0-9]{2}",
icon="fa-table-cells-large",
region_flag="🇮🇪"
region_flag="🇮🇪",
refs_globally_unique=False
),
SIG(
name="DME",
@@ -182,17 +202,20 @@ SIGS = [
description="Diploma Municipios de España",
ref_regex=r"\d{4,5}",
icon="fa-building",
region_flag="🇪🇸"
region_flag="🇪🇸",
refs_globally_unique=False
),
SIG(
name="FEA",
comment_names=["FEA"],
description="Diploma Faros de España",
# FEA references are technically [DE]\-\d{4}(\.\d)? but spotters always seem to miss out the D- or E-
# prefix and just use FEA 1234, so we treat FEA reference IDs as if they were just the number.
ref_regex=r"\d{4}(\.\d)?",
# prefix and just use FEA-1234 or FEA 1234, so allow for that. The FEA sigref data provider adds both
# forms to the database.
ref_regex=r"([DE]|FEA)[\- ]\d{4}(\.\d)?",
icon="fa-house-flood-water",
region_flag="🇪🇸"
region_flag="🇪🇸",
refs_globally_unique=True
),
SIG(
name="DTMBA",
@@ -200,7 +223,8 @@ SIGS = [
description="Diploma Teatri Musei e Belle Arti",
ref_regex=r"I-?[0-9]{3,4}\s?[A-Z]{2}",
icon="fa-masks-theater",
region_flag="🇮🇹"
region_flag="🇮🇹",
refs_globally_unique=True
),
SIG(
name="BIWOTA",
@@ -215,7 +239,8 @@ SIGS = [
description="Toilets on the Air",
ref_regex=r"T\-[0-9]{2}",
icon="fa-toilet",
region_flag="🏴‍☠️"
region_flag="🏴‍☠️",
refs_globally_unique=True
),
]
+5
View File
@@ -19,6 +19,11 @@ def get_sig_ref_info(sig, ref_id):
logger.debug("Failed to look up sig_ref info, sig or ref were not set.")
return None
# Sometimes we allow spaces instead of dashes in references due to common usage that way, but official reference
# lists never do, so convert them here.
ref_id.replace(" ", "-")
# Prepare the object to be returned
sig_ref = SIGRef(sig=sig, id=ref_id)
try:
+3 -2
View File
@@ -1,4 +1,5 @@
import logging
import re
import simplejson
from pyhamtools.frequency import freq_to_band
@@ -30,10 +31,10 @@ def infer_mode_from_comment(comment):
"""Infer a mode from the comment"""
for mode in ALL_MODES:
if mode in comment.upper():
if re.match(r"(^|\W)" + mode + r"(^|\W)", comment, re.IGNORECASE):
return mode
for mode in MODE_ALIASES:
if mode in comment.upper():
if re.match(r"(^|\W)" + mode + r"(^|\W)", comment, re.IGNORECASE):
return MODE_ALIASES[mode]
return None