mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 14:27:42 +00:00
Merge remote-tracking branch 'origin/main'
# Conflicts: # core/constants.py # pyproject.toml # templates/add_spot.html # templates/alerts.html # templates/bands.html # templates/base.html # templates/conditions.html # templates/map.html # templates/spots.html # templates/status.html
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from core.constants import CALL_ONLY_PATTERN
|
||||
import re
|
||||
|
||||
from core.data_providers import DATA_PROVIDERS
|
||||
from data.callsign import Callsign
|
||||
|
||||
@@ -11,7 +12,7 @@ def get_call_info(callsign, lookup_credentials):
|
||||
callsign_data = Callsign(call=callsign)
|
||||
|
||||
# First check our input looks like a real callsign
|
||||
if callsign and CALL_ONLY_PATTERN.match(callsign):
|
||||
if callsign and re.match(r"^[A-Za-z0-9/\-]*$", callsign):
|
||||
# Sort callsign providers by priority order, so we query the highest priority (lowest numbers) first, and only
|
||||
# query other providers for data we are missing as we go along.
|
||||
for p in sorted(DATA_PROVIDERS.callsign_data_providers, key=lambda p2: p2.priority):
|
||||
|
||||
+6
-7
@@ -1,5 +1,3 @@
|
||||
import re
|
||||
|
||||
from core.config import SERVER_OWNER_CALLSIGN
|
||||
from data.band import Band
|
||||
from data.sig import SIG
|
||||
@@ -11,11 +9,6 @@ SOFTWARE_VERSION = "2.0.2-pre"
|
||||
HTTP_HEADERS = {"User-Agent": f"Spothole v{SOFTWARE_VERSION} (operated by {SERVER_OWNER_CALLSIGN})"}
|
||||
HAMQTH_PRG = f"Spothole v{SOFTWARE_VERSION} operated by {SERVER_OWNER_CALLSIGN}".replace(" ", "_")
|
||||
|
||||
# Generally useful regexes
|
||||
CALL_REGEX = r"[A-Za-z0-9/\-]+"
|
||||
CALL_PATTERN = re.compile(CALL_REGEX)
|
||||
CALL_ONLY_PATTERN = re.compile(rf"^{CALL_REGEX}$")
|
||||
|
||||
# Special Interest Groups
|
||||
SIGS = [
|
||||
SIG(
|
||||
@@ -60,6 +53,12 @@ SIGS = [
|
||||
description="Islands on the Air",
|
||||
ref_regex=r"[A-Z]{2}\-\d{3}",
|
||||
),
|
||||
SIG(
|
||||
name="GMA Island",
|
||||
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}))",
|
||||
),
|
||||
SIG(
|
||||
name="MOTA",
|
||||
comment_names=["MOTA"],
|
||||
|
||||
@@ -73,6 +73,20 @@ def get_sig_ref_info(sig, ref_id):
|
||||
sig_ref.url = f"https://www.beachesontheair.com/beaches/{sig_ref.name.lower().replace(' ', '-')}"
|
||||
return sig_ref
|
||||
|
||||
elif sig.upper() == "GMA Islands":
|
||||
# GMA Islands is a bit of a mess of GMA and IOTA references. Try looking them both up and see what returns
|
||||
# the best result.
|
||||
iota_lookup = get_sig_ref_info("IOTA", ref_id)
|
||||
gma_lookup = get_sig_ref_info("GMA", ref_id)
|
||||
for key, value in iota_lookup.__dict__.items():
|
||||
if value is not None and sig_ref.__dict__.get(key) is None:
|
||||
sig_ref.__dict__[key] = value
|
||||
for key, value in gma_lookup.__dict__.items():
|
||||
if value is not None and sig_ref.__dict__.get(key) is None:
|
||||
sig_ref.__dict__[key] = value
|
||||
sig_ref.ref_type = "Island"
|
||||
return sig_ref
|
||||
|
||||
### ACTUAL LOOKUP ###
|
||||
#
|
||||
# OK, this is something we have to look up. Now check to see if our data store contains reference data and use
|
||||
|
||||
Reference in New Issue
Block a user