Files
spothole/providers/callsigndata/countryfiles.py
T

33 lines
1.2 KiB
Python

import logging
from pyhamtools import LookupLib, Callinfo
from core.utils import get_callsign_object_from_pyhamtools_callinfo
from data.callsign import Callsign
from providers.callsigndata.file_download_callsign_data_provider import FileDownloadCallsignDataProvider
class CountryFiles(FileDownloadCallsignDataProvider):
"""Callsign data provider for Country-files.com, which provides basic callsign to DXCC entity mapping."""
POLL_INTERVAL_DAYS = 30
DATA_URL = "https://www.country-files.com/cty/cty.plist"
CACHE_PATH = "cache/cty.plist"
_callinfo = None
def __init__(self, provider_config):
super().__init__("CountryFiles.com", provider_config, self.DATA_URL, self.CACHE_PATH, self.POLL_INTERVAL_DAYS)
def _handle_file(self, path):
try:
lookuplib = LookupLib(lookuptype="countryfile", filename=path)
self._callinfo = Callinfo(lookuplib)
return True
except Exception as e:
logging.error("Exception when loading Country Files cty.plist.", e, exc_info=True)
return False
def lookup(self, callsign, lookup_credentials):
return get_callsign_object_from_pyhamtools_callinfo(callsign, self._callinfo)