mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-05 18:11:41 +00:00
Refactor of caching & data storage part 11 #118
This commit is contained in:
+28
-1
@@ -5,6 +5,7 @@ from pyhamtools.frequency import freq_to_band
|
||||
|
||||
from core.constants import UNKNOWN_BAND, BANDS, CW_MODES, PHONE_MODES, DATA_MODES, MODE_ALIASES, ALL_MODES
|
||||
from core.data_store import DATA_STORE
|
||||
from data.callsign import Callsign
|
||||
|
||||
|
||||
def safe_json_dumps(obj):
|
||||
@@ -76,4 +77,30 @@ def get_flag_for_dxcc(dxcc):
|
||||
"""Get an emoji flag for a given DXCC entity ID"""
|
||||
|
||||
dxcc_data = DATA_STORE.dxcc_data[dxcc] if dxcc in DATA_STORE.dxcc_data else None
|
||||
return dxcc_data["flag"] if dxcc_data else None
|
||||
return dxcc_data["flag"] if dxcc_data else None
|
||||
|
||||
|
||||
def get_callsign_object_from_pyhamtools_callinfo(callsign, callinfo):
|
||||
"""Utility function to take the data provided by a PyHamTools CallInfo object and populate our own Callsign data
|
||||
object from it"""
|
||||
|
||||
home_call = callinfo.get_homecall(callsign)
|
||||
data = callinfo.get_all()
|
||||
|
||||
country = data["country"] if "country" in data else None
|
||||
dxcc_id = data["adif"] if "adif" in data else None
|
||||
continent = data["continent"] if "continent" in data else None
|
||||
cq_zone = data["cqz"] if "cqz" in data else None
|
||||
itu_zone = data["ituz"] if "ituz" in data else None
|
||||
lat = float(data["latitude"]) if "latitude" in data else None
|
||||
lon = float(data["longitude"]) if "longitude" in data else None
|
||||
|
||||
return Callsign(call=callsign,
|
||||
home_call=home_call,
|
||||
country=country,
|
||||
dxcc_id=dxcc_id,
|
||||
continent=continent,
|
||||
cq_zone=cq_zone,
|
||||
itu_zone=itu_zone,
|
||||
latitude=lat,
|
||||
longitude=lon)
|
||||
|
||||
Reference in New Issue
Block a user