Split out event type SIGs, and do other enum conversions. Closes #138

This commit is contained in:
Ian Renton
2026-09-02 09:38:05 +01:00
parent 606cf1be68
commit 9d117a6069
54 changed files with 363 additions and 155 deletions
+1 -1
View File
@@ -93,7 +93,7 @@ class Alert:
if self.dx_calls and self.dx_calls[0] and not self.dx_country:
self.dx_country = call_info.country
if self.dx_calls and self.dx_calls[0] and not self.dx_continent:
self.dx_continent = Continent(call_info.continent)
self.dx_continent = Continent(call_info.continent) if call_info.continent else None
if self.dx_calls and self.dx_calls[0] and not self.dx_cq_zone:
self.dx_cq_zone = call_info.cq_zone
if self.dx_calls and self.dx_calls[0] and not self.dx_itu_zone:
+9 -5
View File
@@ -1,5 +1,7 @@
from dataclasses import dataclass, field
from core.enums import SIGType
@dataclass
class SIG:
@@ -15,16 +17,18 @@ class SIG:
name: str
# Description, e.g. "Towers on the Air"
description: str
# SIG names as they might appear in cluster spot comments, e.g. ["TOTA"]
comment_names: list[str] = field(default_factory=list)
# Regex matcher for references, e.g. for POTA r"[A-Z]{2}\-\d+".
ref_regex: str | None = None
# Type, either Worldwide, Regional or Event. Used for sorting in the web UI.
sig_type: SIGType
# Identifies that the SIG's reference ID structure defined by its regex is unique across all programmes and
# anything else we expect a user to put in a spot comment, and therefore we can pull references out of
# spot comments without also needing to see the SIG name first. For example, "OHFF-1234" or "B/G-1234" are
# obviously WWFF and WWBOTA, nothing else looks like those. But "SZ09" could be WAB or Tiles, "GB1234" could
# conceivably be POTA or ILLW, etc.
refs_globally_unique: bool = False
refs_globally_unique: bool
# SIG names as they might appear in cluster spot comments, e.g. ["TOTA"]
comment_names: list[str] = field(default_factory=list)
# Regex matcher for references, e.g. for POTA r"[A-Z]{2}\-\d+".
ref_regex: str | None = None
# Icon to use in the UI when referencing this SIG. Chosen from the Font Awesome set.
icon: str | None = None
# Emoji flag for the country or region where this SIG is relevant, if any. If None, this implies the SIG is in
+3 -1
View File
@@ -1,5 +1,7 @@
from dataclasses import dataclass
from core.enums import SIGRefType
@dataclass
class SIGRef:
@@ -13,7 +15,7 @@ class SIGRef:
# Name of the reference, e.g. "Null Country Park", if known.
name: str | None = None
# Type of the reference, e.g. "Park", if known.
ref_type: str | None = None
ref_type: SIGRefType = SIGRefType.UNKNOWN
# URL to look up more information about the reference, if known.
url: str | None = None
# Latitude of the reference, in degrees, if known.
+11 -11
View File
@@ -11,8 +11,8 @@ from pyhamtools.locator import latlong_to_locator, locator_to_latlong
from core.call_lookup_helper import get_call_info
from core.config import MAX_SPOT_AGE
from core.constants import MODE_ALIASES, PROPAGATION_MODES, SIGS
from core.enums import Continent, LocationSourceForSpot, ModeSource, ModeType
from core.constants import PROPAGATION_MODES, SIGS
from core.enums import Continent, LocationSourceForSpot, Mode, ModeSource, ModeType
from core.geo_utils import lat_lon_to_cq_zone, lat_lon_to_itu_zone
from core.sig_lookup_helper import populate_missing_sig_ref_info
from core.sig_utils import (
@@ -103,7 +103,7 @@ class Spot:
# General QSO info
# Reported mode, such as SSB, PHONE, CW, FT8...
mode: str | None = None
mode: Mode = Mode.UNKNOWN
# Inferred mode "family".
mode_type: ModeType = ModeType.UNKNOWN
# Source of the mode information.
@@ -239,21 +239,21 @@ class Spot:
self.band = band.name
# Mode from comments or bandplan
if self.mode:
if not self.mode:
self.mode = Mode.UNKNOWN
if self.mode != Mode.UNKNOWN:
self.mode_source = ModeSource.SPOT
if self.comment and not self.mode:
if self.comment and self.mode == Mode.UNKNOWN:
self.mode = infer_mode_from_comment(self.comment)
self.mode_source = ModeSource.COMMENT
if self.freq and not self.mode:
if self.freq and self.mode == Mode.UNKNOWN:
self.mode = infer_mode_from_frequency(self.freq)
self.mode_source = ModeSource.BANDPLAN
# Normalise mode if necessary.
if self.mode in MODE_ALIASES:
self.mode = MODE_ALIASES[self.mode]
# Mode type from mode
if self.mode and not self.mode_type:
if not self.mode_type:
self.mode_type = ModeType.UNKNOWN
if self.mode != Mode.UNKNOWN and self.mode_type == ModeType.UNKNOWN:
self.mode_type = infer_mode_type_from_mode(self.mode)
# If we have a latitude or grid at this point, it can only have been provided by the spot itself