mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-06 02:21:42 +00:00
Refactor of caching & data storage part 9 #118
This commit is contained in:
+2
-1
@@ -9,6 +9,7 @@ import pytz
|
||||
|
||||
from core.call_lookup_helper import lookup_helper
|
||||
from core.sig_lookup_helper import populate_sig_ref_info
|
||||
from core.utils import get_flag_for_dxcc
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -96,7 +97,7 @@ class Alert:
|
||||
if self.dx_calls and self.dx_calls[0] and not self.dx_dxcc_id:
|
||||
self.dx_dxcc_id = lookup_helper.infer_dxcc_id_from_callsign(self.dx_calls[0], credentials)
|
||||
if self.dx_dxcc_id and not self.dx_flag:
|
||||
self.dx_flag = lookup_helper.get_flag_for_dxcc(self.dx_dxcc_id)
|
||||
self.dx_flag = get_flag_for_dxcc(self.dx_dxcc_id)
|
||||
|
||||
# Fetch SIG data. In case a particular API doesn't provide a full set of name, lat, lon & grid for a reference
|
||||
# in its initial call, we use this code to populate the rest of the data. This includes working out grid refs
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class Callsign:
|
||||
"""Data class that defines a callsign and the data associated with it. This will have been retrieved by a callsign
|
||||
lookup provider using data files or online lookup. This can be used to infer missing data for a spot, though if the
|
||||
spot has a SIG (e.g. POTA) reference this data for their home location (or even just their country) will be less
|
||||
accurate and should not be used in preference to that."""
|
||||
|
||||
# Callsign as spotted
|
||||
call: str
|
||||
# "Home" call, i.e. with any prefixes and suffixes stripped off
|
||||
home_call: str
|
||||
# Operator name
|
||||
name : str | None = None
|
||||
# QTH (location), free text
|
||||
qth : str | None = None
|
||||
# Maidenhead grid locator. Depending on the source of lookup this could be a home location from QRZ/HamQTH or just
|
||||
# the centre of the country they're operating in if no other data is available.
|
||||
grid : str | None = None
|
||||
# Latitude. Depending on the source of lookup this could be a home location from QRZ/HamQTH or just
|
||||
# the centre of the country they're operating in if no other data is available.
|
||||
latitude : float | None = None
|
||||
# Longitude. Depending on the source of lookup this could be a home location from QRZ/HamQTH or just
|
||||
# the centre of the country they're operating in if no other data is available.
|
||||
longitude : float | None = None
|
||||
# Country in which the callsign indicates they are operating
|
||||
dx_country: str | None = None
|
||||
# Continent in which the callsign indicates they are operating
|
||||
dx_continent: str | None = None
|
||||
# DXCC ID in which the callsign indicates they are operating
|
||||
dx_dxcc_id: int | None = None
|
||||
# CQ zone in which the callsign indicates they are operating
|
||||
dx_cq_zone: int | None = None
|
||||
# ITU zone in which the callsign indicates they are operating
|
||||
dx_itu_zone: int | None = None
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@ from core.call_lookup_helper import lookup_helper
|
||||
from core.sig_utils import ANY_SIG_REGEX, get_ref_regex_for_sig, get_sig_name_from_comment_name
|
||||
from core.sig_lookup_helper import populate_sig_ref_info
|
||||
from core.utils import infer_band_from_freq, infer_mode_from_comment, \
|
||||
infer_mode_from_frequency, infer_mode_type_from_mode
|
||||
infer_mode_from_frequency, infer_mode_type_from_mode, get_flag_for_dxcc
|
||||
from data.sig_ref import SIGRef
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ class Spot:
|
||||
if self.dx_call and not self.dx_dxcc_id:
|
||||
self.dx_dxcc_id = lookup_helper.infer_dxcc_id_from_callsign(self.dx_call, credentials)
|
||||
if self.dx_dxcc_id and not self.dx_flag:
|
||||
self.dx_flag = lookup_helper.get_flag_for_dxcc(self.dx_dxcc_id)
|
||||
self.dx_flag = get_flag_for_dxcc(self.dx_dxcc_id)
|
||||
|
||||
# Clean up spotter call if it has an SSID or -# from RBN
|
||||
if self.de_call and "-" in self.de_call:
|
||||
@@ -214,7 +214,7 @@ class Spot:
|
||||
if not self.de_dxcc_id:
|
||||
self.de_dxcc_id = lookup_helper.infer_dxcc_id_from_callsign(self.de_call, credentials)
|
||||
if self.de_dxcc_id and not self.de_flag:
|
||||
self.de_flag = lookup_helper.get_flag_for_dxcc(self.de_dxcc_id)
|
||||
self.de_flag = get_flag_for_dxcc(self.de_dxcc_id)
|
||||
|
||||
# Remove NaNs in frequency
|
||||
if self.freq and self.freq == float("nan"):
|
||||
|
||||
Reference in New Issue
Block a user