mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 22:37:44 +00:00
Start converting some enum-like strings to proper enums, plus global reformat
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
@@ -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.")
|
||||
|
||||
Reference in New Issue
Block a user