Start converting some enum-like strings to proper enums, plus global reformat

This commit is contained in:
Ian Renton
2026-09-02 08:37:13 +01:00
parent 5a6fc19ab5
commit 606cf1be68
24 changed files with 81 additions and 79 deletions
-1
View File
@@ -276,7 +276,6 @@ DATA_MODES = [
"MSK144",
]
ALL_MODES = CW_MODES + PHONE_MODES + DATA_MODES
MODE_TYPES = ["CW", "PHONE", "DATA"]
# Mode aliases. Sometimes we get spots with a mode described in a different way that is effectively the same as a mode
# we already know, or we want to normalise things for consistency. The lookup table for this is here. Incoming spots
+7
View File
@@ -11,6 +11,13 @@ class Continent(str, Enum):
AN = "AN"
class ModeType(str, Enum):
PHONE = "PHONE"
CW = "CW"
DATA = "DATA"
UNKNOWN = "UNKNOWN"
class ModeSource(str, Enum):
"""Where the mode data came from in a spot."""
+4 -4
View File
@@ -15,7 +15,7 @@ from core.constants import (
UNKNOWN_BAND,
)
from core.data_store import DATA_STORE
from core.enums import Continent
from core.enums import Continent, ModeType
from data.callsign import Callsign, LocationSourceForCallsign
logger = logging.getLogger(__name__)
@@ -44,11 +44,11 @@ def infer_mode_type_from_mode(mode):
"""Infer a "mode family" from a mode."""
if mode.upper() in CW_MODES:
return "CW"
return ModeType.CW
elif mode.upper() in PHONE_MODES:
return "PHONE"
return ModeType.PHONE
elif mode.upper() in DATA_MODES:
return "DATA"
return ModeType.DATA
else:
if mode.upper() != "OTHER" and mode != "?":
logger.warning(f"Found an unrecognised mode: {mode}. Developer should categorise this.")