LookupLib

class pyhamtools.lookuplib.LookupLib(lookuptype='clublogxml', apikey=None, filename=None, logger=None)

This class provides a homogeneous interface to three different Amateur Radio Callsign lookup sources:

  1. Clublog.org (daily updated XML File)
  2. Clublog.org (HTTPS lookup)
  3. Country-files.com (infrequently updated PLIST File)

The class provides getters to access the data in a structured way. Even the interface is the same for all lookup sources, the returning data can be different. The documentation of the various methods provide more detail.

By default, LookupLib requires an Internet connection to download the libraries or perform the lookup against the Clublog API.

Parameters:
  • lookuptype (str) – “clublogxml” or “clublogapi” or “countryfile”
  • apikey (str) – Clublog API Key
  • filename (str, optional) – Filename for Clublog XML or Country-files.com cty.plist file
  • logger (logging.getLogger(__name__), optional) – Python logger
is_invalid_operation(callsign, timestamp=datetime.datetime(2014, 4, 24, 15, 46, 11, 956076, tzinfo=<UTC>))

Returns True if an operations is known as invalid

Parameters:
  • callsign (string) – Amateur Radio callsign
  • timestamp (datetime, optional) – datetime in UTC (tzinfo=pytz.UTC)
Returns:

True if a record exists for this callsign (at the given time)

Return type:

bool

Raises:
  • NoResult – No matching callsign found
  • APIKeyMissingError – API Key for Clublog missing or incorrect

Note

This method is available for

  • clublogxml
lookup_callsign(callsign=None, timestamp=datetime.datetime(2014, 4, 24, 15, 46, 11, 956058, tzinfo=<UTC>))

Returns lookup data if an exception exists for a callsign

Parameters:
  • callsign (string) – Amateur radio callsign
  • timestamp (datetime, optional) – datetime in UTC (tzinfo=pytz.UTC)
Returns:

Dictionary containing the country specific data of the callsign

Return type:

dict

Raises:
  • NoResult – No matching callsign found
  • APIKeyMissingError – API Key for Clublog missing or incorrect

Note

This method is available for

  • clublogxml
  • clublogapi
  • countryfile
lookup_entity(entity=None)

Returns lookup data of a ADIF Entity

Parameters:entity (int) – ADIF identifier of country
Returns:Dictionary containing the country specific data
Return type:dict
Raises:NoResult – No matching entity found

Note

This method is available for the following lookup type

  • clublogxml
lookup_prefix(prefix, timestamp=datetime.datetime(2014, 4, 24, 15, 46, 11, 956058, tzinfo=<UTC>))

Returns lookup data of a Prefix

Parameters:
  • prefix (string) – Prefix of a Amateur Radio callsign
  • timestamp (datetime, optional) – datetime in UTC (tzinfo=pytz.UTC)
Returns:

Dictionary containing the country specific data of the Prefix

Return type:

dict

Raises:
  • NoResult – No matching Prefix found
  • APIKeyMissingError – API Key for Clublog missing or incorrect

Note

This method is available for

  • clublogxml
  • countryfile
lookup_zone_exception(callsign, timestamp=datetime.datetime(2014, 4, 24, 15, 46, 11, 956082, tzinfo=<UTC>))

Returns a CQ Zone if an exception exists for the given callsign

Args: callsign (string): Amateur radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)

Returns:

Value of the the CQ Zone exception which exists for this callsign (at the given time)

Return type:

int

Raises:
  • NoResult – No matching callsign found
  • APIKeyMissingError – API Key for Clublog missing or incorrect

Note

This method is available for

  • clublogxml

Previous topic

PyHamTools

This Page