Support RSGB contests

This commit is contained in:
Ian Renton
2026-09-05 09:00:32 +01:00
parent d3d1d20821
commit d6e53c14e9
32 changed files with 256 additions and 98 deletions
+11 -6
View File
@@ -30,7 +30,6 @@ class Mode(str, Enum):
OLIVIA = "OLIVIA"
PKT = "PKT"
MSK144 = "MSK144"
UNKNOWN = "UNKNOWN"
@property
def is_cw(self) -> bool:
@@ -42,14 +41,14 @@ class Mode(str, Enum):
@property
def is_data(self) -> bool:
return not (self.is_cw or self.is_phone or self == Mode.UNKNOWN)
return not (self.is_cw or self.is_phone)
@staticmethod
def from_name(name):
"""Convert a string to an enum mode using the alias table."""
if not name:
return Mode.UNKNOWN
return None
try:
return Mode(name.upper())
@@ -57,14 +56,13 @@ class Mode(str, Enum):
try:
return Mode(MODE_ALIASES[name.upper()])
except (KeyError, ValueError):
return Mode.UNKNOWN
return None
class ModeType(str, Enum):
PHONE = "PHONE"
CW = "CW"
DATA = "DATA"
UNKNOWN = "UNKNOWN"
class ModeSource(str, Enum):
@@ -115,7 +113,14 @@ class SIGRefType(str, Enum):
REGION = "REGION"
GRID = "GRID"
TOILET = "TOILET"
UNKNOWN = "UNKNOWN"
class AlertType(str, Enum):
"""Type of an alert."""
XOTA = "XOTA"
DXPEDITION = "DXPEDITION"
CONTEST = "CONTEST"
class SIGType(str, Enum):
+6 -6
View File
@@ -20,11 +20,11 @@ def safe_json_dumps(obj):
return simplejson.dumps(obj, ensure_ascii=False, ignore_nan=True, default=lambda o: o.__dict__)
def infer_mode_from_comment(comment: str) -> Mode:
def infer_mode_from_comment(comment: str) -> Mode | None:
"""Infer a mode from the comment"""
if not comment:
return Mode.UNKNOWN
return None
for mode in Mode:
if re.search(r"(^|\W)" + mode + r"($|\W)", comment, re.IGNORECASE):
@@ -33,14 +33,14 @@ def infer_mode_from_comment(comment: str) -> Mode:
if re.search(r"(^|\W)" + alias + r"($|\W)", comment, re.IGNORECASE):
return Mode(MODE_ALIASES[alias])
return Mode.UNKNOWN
return None
def infer_mode_type_from_mode(mode: str) -> ModeType:
def infer_mode_type_from_mode(mode: str) -> ModeType | None:
"""Infer a "mode family" from a mode ."""
if not mode:
return ModeType.UNKNOWN
return None
if mode in MODE_ALIASES:
mode = MODE_ALIASES[mode]
@@ -56,7 +56,7 @@ def infer_mode_type_from_mode(mode: str) -> ModeType:
except ValueError:
if mode.upper() != "OTHER" and mode != "?":
logger.warning(f"Found an unrecognised mode: {mode}. Developer should categorise this.")
return ModeType.UNKNOWN
return None
def infer_band_from_freq(freq):