diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..821f715 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +docs/build +settings.json diff --git a/docs/build/doctrees/Callinfo.doctree b/docs/build/doctrees/Callinfo.doctree deleted file mode 100644 index 54392ec..0000000 Binary files a/docs/build/doctrees/Callinfo.doctree and /dev/null differ diff --git a/docs/build/doctrees/environment.pickle b/docs/build/doctrees/environment.pickle deleted file mode 100644 index ed57e1b..0000000 Binary files a/docs/build/doctrees/environment.pickle and /dev/null differ diff --git a/docs/build/doctrees/help.doctree b/docs/build/doctrees/help.doctree deleted file mode 100644 index e2f62dd..0000000 Binary files a/docs/build/doctrees/help.doctree and /dev/null differ diff --git a/docs/build/doctrees/index.doctree b/docs/build/doctrees/index.doctree deleted file mode 100644 index 6bd28f3..0000000 Binary files a/docs/build/doctrees/index.doctree and /dev/null differ diff --git a/docs/build/doctrees/license.doctree b/docs/build/doctrees/license.doctree deleted file mode 100644 index 50a4e9c..0000000 Binary files a/docs/build/doctrees/license.doctree and /dev/null differ diff --git a/docs/build/doctrees/lookuplib.doctree b/docs/build/doctrees/lookuplib.doctree deleted file mode 100644 index a3b43dc..0000000 Binary files a/docs/build/doctrees/lookuplib.doctree and /dev/null differ diff --git a/docs/build/html/.buildinfo b/docs/build/html/.buildinfo deleted file mode 100644 index 7a71a0b..0000000 --- a/docs/build/html/.buildinfo +++ /dev/null @@ -1,4 +0,0 @@ -# Sphinx build info version 1 -# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 7a49ae1f4a901a2bfa6bcbedb16df815 -tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/build/html/Callinfo.html b/docs/build/html/Callinfo.html deleted file mode 100644 index f99d373..0000000 --- a/docs/build/html/Callinfo.html +++ /dev/null @@ -1,450 +0,0 @@ - - - - -
- - -The purpose of this class is to return data (country, latitude, longitude, CQ Zone...etc) for an -Amateur Radio callsign. The class can be used with any lookup database, -provided through an Instance of LookupLib. -An instance of Lookuplib has to be injected on object construction.
-| Parameters: |
|
-
|---|
Returns ADIF id of a callsign’s country
-| Parameters: |
|
-
|---|---|
| Returns: | containing the country ADIF id - |
-
| Return type: | int - |
-
| Raises: | KeyError – -No Country found for callsign - |
-
Lookup a callsign and return all data available from the underlying database
-| Parameters: |
|
-
|---|---|
| Returns: | Dictionary containing the callsign specific data - |
-
| Return type: | dict - |
-
| Raises: | KeyError – -Callsign could not be identified - |
-
Example
-The following code returns all available information from the country-files.com database for the -callsign “DH1TW”
->>> from pyhamtools import LookupLib, Callinfo
->>> my_lookuplib = LookupLib(lookuptype="countryfile")
->>> cic = Callinfo(my_lookuplib)
->>> cic.get_all("DH1TW")
-{
- 'country': 'Fed. Rep. of Germany',
- 'adif': 230,
- 'continent': 'EU',
- 'latitude': 51.0,
- 'longitude': -10.0,
- 'cqz': 14,
- 'ituz': 28
-}
-Note
-The content of the returned data depends entirely on the injected -LookupLib (and the used database). While the country-files.com provides -for example the ITU Zone, Clublog doesn’t. Consequently, the item “ituz” -would be missing with Clublog (API or XML) LookupLib.
-Returns the continent Identifier of a callsign
-| Parameters: |
|
-
|---|---|
| Returns: | continent identified - |
-
| Return type: | str - |
-
| Raises: | KeyError – -No Continent found for callsign - |
-
Note
-The following continent identifiers are used:
-Returns the country name where the callsign is located
-| Parameters: |
|
-
|---|---|
| Returns: | name of the Country - |
-
| Return type: | str - |
-
| Raises: | KeyError – -No Country found for callsign - |
-
Note
-Don’t rely on the country name when working with several instances of -py:class:Callinfo. Clublog and Country-files.org use slightly different names -for countries. Example:
-Returns CQ Zone of a callsign
-| Parameters: |
|
-
|---|---|
| Returns: | containing the callsign’s CQ Zone - |
-
| Return type: | int - |
-
| Raises: | KeyError – -no CQ Zone found for callsign - |
-
Strips off country prefixes (HC2/DH1TW) and activity suffixes (DH1TW/P).
-| Parameters: | callsign (str) – Amateur Radio callsign | -
|---|---|
| Returns: | callsign without country/activity pre/suffixes | -
| Return type: | str | -
| Raises: | ValueError – -No callsign found in string | -
Example
-The following code retrieves the home call for “HC2/DH1TW/P”
->>> from pyhamtools import LookupLib, Callinfo
->>> my_lookuplib = LookupLib(lookuptype="countryfile")
->>> cic = Callinfo(my_lookuplib)
->>> cic.get_homecall("HC2/DH1TW/P")
-DH1TW
-Returns ITU Zone of a callsign
-| Parameters: |
|
-
|---|---|
| Returns: | containing the callsign’s CQ Zone - |
-
| Return type: | int - |
-
| Raises: | KeyError – -No ITU Zone found for callsign - |
-
Note
-Currently, only Country-files.com lookup database contains ITU Zones
-Returns Latitude and Longitude for a callsign
-| Parameters: |
|
-
|---|---|
| Returns: | Containing Latitude and Longitude - |
-
| Return type: | dict - |
-
| Raises: | KeyError – -No data found for callsign - |
-
Example
-The following code returns Latitude & Longitude for “DH1TW”
->>> from pyhamtools import LookupLib, Callinfo
->>> my_lookuplib = LookupLib(lookuptype="countryfile")
->>> cic = Callinfo(my_lookuplib)
->>> cic.get_lat_long("DH1TW")
-{
- 'latitude': 51.0,
- 'longitude': -10.0
-}
-Note
-Unfortunately, in most cases the returned Latitude and Longitude are not very precise. -Clublog and Country-files.com use the country’s capital coordinates in most cases, if no -dedicated entry in the database exists.
-Checks if a callsign is valid
-| Parameters: |
|
-
|---|---|
| Returns: | True / False - |
-
| Return type: | bool - |
-
Example
-The following checks if “DH1TW” is a valid callsign
->>> from pyhamtools import LookupLib, Callinfo
->>> my_lookuplib = LookupLib(lookuptype="countryfile")
->>> cic = Callinfo(my_lookuplib)
->>> cic.is_valid_callsign("DH1TW")
-True
-' + _('Hide Search Matches') + '
') - .appendTo($('#searchbox')); - } - }, - - /** - * init the domain index toggle buttons - */ - initIndexTable : function() { - var togglers = $('img.toggler').click(function() { - var src = $(this).attr('src'); - var idnum = $(this).attr('id').substr(7); - $('tr.cg-' + idnum).toggle(); - if (src.substr(-9) == 'minus.png') - $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); - else - $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); - }).css('display', ''); - if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) { - togglers.click(); - } - }, - - /** - * helper function to hide the search marks again - */ - hideSearchWords : function() { - $('#searchbox .highlight-link').fadeOut(300); - $('span.highlighted').removeClass('highlighted'); - }, - - /** - * make the url absolute - */ - makeURL : function(relativeURL) { - return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL; - }, - - /** - * get the current relative url - */ - getCurrentURL : function() { - var path = document.location.pathname; - var parts = path.split(/\//); - $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { - if (this == '..') - parts.pop(); - }); - var url = parts.join('/'); - return path.substring(url.lastIndexOf('/') + 1, path.length - 1); - } -}; - -// quick alias for translations -_ = Documentation.gettext; - -$(document).ready(function() { - Documentation.init(); -}); diff --git a/docs/build/html/_static/down-pressed.png b/docs/build/html/_static/down-pressed.png deleted file mode 100644 index 6f7ad78..0000000 Binary files a/docs/build/html/_static/down-pressed.png and /dev/null differ diff --git a/docs/build/html/_static/down.png b/docs/build/html/_static/down.png deleted file mode 100644 index 3003a88..0000000 Binary files a/docs/build/html/_static/down.png and /dev/null differ diff --git a/docs/build/html/_static/file.png b/docs/build/html/_static/file.png deleted file mode 100644 index d18082e..0000000 Binary files a/docs/build/html/_static/file.png and /dev/null differ diff --git a/docs/build/html/_static/jquery.js b/docs/build/html/_static/jquery.js deleted file mode 100644 index 83589da..0000000 --- a/docs/build/html/_static/jquery.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! jQuery v1.8.3 jquery.com | jquery.org/license */ -(function(e,t){function _(e){var t=M[e]={};return v.each(e.split(y),function(e,n){t[n]=!0}),t}function H(e,n,r){if(r===t&&e.nodeType===1){var i="data-"+n.replace(P,"-$1").toLowerCase();r=e.getAttribute(i);if(typeof r=="string"){try{r=r==="true"?!0:r==="false"?!1:r==="null"?null:+r+""===r?+r:D.test(r)?v.parseJSON(r):r}catch(s){}v.data(e,n,r)}else r=t}return r}function B(e){var t;for(t in e){if(t==="data"&&v.isEmptyObject(e[t]))continue;if(t!=="toJSON")return!1}return!0}function et(){return!1}function tt(){return!0}function ut(e){return!e||!e.parentNode||e.parentNode.nodeType===11}function at(e,t){do e=e[t];while(e&&e.nodeType!==1);return e}function ft(e,t,n){t=t||0;if(v.isFunction(t))return v.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return v.grep(e,function(e,r){return e===t===n});if(typeof t=="string"){var r=v.grep(e,function(e){return e.nodeType===1});if(it.test(t))return v.filter(t,r,!n);t=v.filter(t,r)}return v.grep(e,function(e,r){return v.inArray(e,t)>=0===n})}function lt(e){var t=ct.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function At(e,t){if(t.nodeType!==1||!v.hasData(e))return;var n,r,i,s=v._data(e),o=v._data(t,s),u=s.events;if(u){delete o.handle,o.events={};for(n in u)for(r=0,i=u[n].length;r").appendTo(i.body),n=t.css("display");t.remove();if(n==="none"||n===""){Pt=i.body.appendChild(Pt||v.extend(i.createElement("iframe"),{frameBorder:0,width:0,height:0}));if(!Ht||!Pt.createElement)Ht=(Pt.contentWindow||Pt.contentDocument).document,Ht.write(""),Ht.close();t=Ht.body.appendChild(Ht.createElement(e)),n=Dt(t,"display"),i.body.removeChild(Pt)}return Wt[e]=n,n}function fn(e,t,n,r){var i;if(v.isArray(t))v.each(t,function(t,i){n||sn.test(e)?r(e,i):fn(e+"["+(typeof i=="object"?t:"")+"]",i,n,r)});else if(!n&&v.type(t)==="object")for(i in t)fn(e+"["+i+"]",t[i],n,r);else r(e,t)}function Cn(e){return function(t,n){typeof t!="string"&&(n=t,t="*");var r,i,s,o=t.toLowerCase().split(y),u=0,a=o.length;if(v.isFunction(n))for(;u)[^>]*$|#([\w\-]*)$)/,E=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,S=/^[\],:{}\s]*$/,x=/(?:^|:|,)(?:\s*\[)+/g,T=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,N=/"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,C=/^-ms-/,k=/-([\da-z])/gi,L=function(e,t){return(t+"").toUpperCase()},A=function(){i.addEventListener?(i.removeEventListener("DOMContentLoaded",A,!1),v.ready()):i.readyState==="complete"&&(i.detachEvent("onreadystatechange",A),v.ready())},O={};v.fn=v.prototype={constructor:v,init:function(e,n,r){var s,o,u,a;if(!e)return this;if(e.nodeType)return this.context=this[0]=e,this.length=1,this;if(typeof e=="string"){e.charAt(0)==="<"&&e.charAt(e.length-1)===">"&&e.length>=3?s=[null,e,null]:s=w.exec(e);if(s&&(s[1]||!n)){if(s[1])return n=n instanceof v?n[0]:n,a=n&&n.nodeType?n.ownerDocument||n:i,e=v.parseHTML(s[1],a,!0),E.test(s[1])&&v.isPlainObject(n)&&this.attr.call(e,n,!0),v.merge(this,e);o=i.getElementById(s[2]);if(o&&o.parentNode){if(o.id!==s[2])return r.find(e);this.length=1,this[0]=o}return this.context=i,this.selector=e,this}return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e)}return v.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),v.makeArray(e,this))},selector:"",jquery:"1.8.3",length:0,size:function(){return this.length},toArray:function(){return l.call(this)},get:function(e){return e==null?this.toArray():e<0?this[this.length+e]:this[e]},pushStack:function(e,t,n){var r=v.merge(this.constructor(),e);return r.prevObject=this,r.context=this.context,t==="find"?r.selector=this.selector+(this.selector?" ":"")+n:t&&(r.selector=this.selector+"."+t+"("+n+")"),r},each:function(e,t){return v.each(this,e,t)},ready:function(e){return v.ready.promise().done(e),this},eq:function(e){return e=+e,e===-1?this.slice(e):this.slice(e,e+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(l.apply(this,arguments),"slice",l.call(arguments).join(","))},map:function(e){return this.pushStack(v.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:[].sort,splice:[].splice},v.fn.init.prototype=v.fn,v.extend=v.fn.extend=function(){var e,n,r,i,s,o,u=arguments[0]||{},a=1,f=arguments.length,l=!1;typeof u=="boolean"&&(l=u,u=arguments[1]||{},a=2),typeof u!="object"&&!v.isFunction(u)&&(u={}),f===a&&(u=this,--a);for(;a| t |
| - | - |
|
-
| - | - |
| - | - |
|
-
|
-
For help contact DH1TW
-| Version: | 0.4.2 | -
|---|---|
| Code: | https://github.com/dh1tw/pyhamtools | -
| License: | MIT; see license file | -
| Issues: | https://github.com/dh1tw/pyhamtools/issues | -
| Documentation: | http://pyhamtools.readthedocs.org/ | -
| IRC: | #hamtests on webirc.deltaxray.org | -
PyHamTools is a Python library which helps you creating Amateur Radio applications faster. It comes -with some modules and classes which are frequently needed:
----
-- Locator based calculations (distance, heading, sunrise/sunset, Locator to Lat/Long conversion)
-- Checking frequencies against the IARU bandplan or
-- Parsing Amateur Radio callsigns using Clublog.org‘s or AD1C’s Country-Files.com database
-
PyHamTools is used in production at the DXHeat.com DXCluster, performing several thousand lookups and calculations per day.
- -The MIT License (MIT)
-Copyright (c) 2014 Tobias Wellnitz
-Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the “Software”), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.
-Contact Tobias@dh1tw.de
-This class is a wrapper for the following three Amateur Radio databases:
-It’s aim is to provide a homogeneous interface to different databases.
-Typically an instance of this class is injected as a dependency in the Callinfo class, but it can also -be used directly.
-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.
-The entire lookup data can also be copied into Redis, which an extremely fast in-memory Key/Value store. -A LookupLib object can be instanciated to perform then all lookups in Redis, instead processing and loading -the data from Internet / File. This saves some time and allows several instances of LookupLib -to query the same data concurrently.
-| Parameters: |
|
-
|---|
Copy the complete lookup data into redis. Old data will be overwritten.
-| Parameters: |
|
-
|---|---|
| Returns: | returns True when the data has been copied successfully into Redis - |
-
| Return type: | bool - |
-
Example
-Copy the entire lookup data from the Country-files.com PLIST File into Redis. This example requires a running -instance of Redis, as well the python Redis connector (pip install redis-py).
->>> from pyhamtools import LookupLib
->>> import redis
->>> r = redis.Redis()
->>> my_lookuplib = LookupLib(lookuptype="countryfile")
->>> print my_lookuplib.copy_data_in_redis(redis_prefix="CF", redis_instance=r)
-True
-Now let’s create an instance of LookupLib, using Redis to query the data
->>> from pyhamtools import LookupLib
->>> import redis
->>> r = redis.Redis()
->>> my_lookuplib = LookupLib(lookuptype="countryfile", redis_instance=r, redis_prefix="CF")
->>> my_lookuplib.lookup_callsign("3D2RI")
-{
- u'adif': 460,
- u'continent': 'OC',
- u'country': 'Rotuma Island',
- u'cqz': 32,
- u'ituz': 56,
- u'latitude': -12.48,
- u'longitude': -177.08
-}
-Note
-This method is available for the following lookup type
-Returns True if an operations is known as invalid
-| Parameters: |
|
-
|---|---|
| Returns: | True if a record exists for this callsign (at the given time) - |
-
| Return type: | bool - |
-
| Raises: |
|
-
Example
-The following code checks the Clublog XML database if the operation is valid for two dates.
->>> from pyhamtools import LookupLib
->>> from datetime import datetime
->>> import pytz
->>> my_lookuplib = LookupLib(lookuptype="clublogxml", apikey="myapikey")
->>> print my_lookuplib.is_invalid_operation("5W1CFN")
-True
->>> try:
->>> timestamp = datetime(year=2012, month=1, day=31).replace(tzinfo=pytz.UTC)
->>> my_lookuplib.is_invalid_operation("5W1CFN", timestamp)
->>> except KeyError:
->>> print "Seems to be invalid operation before 31.1.2012"
-Seems to be an invalid operation before 31.1.2012
-Note
-This method is available for
-Returns lookup data if an exception exists for a callsign
-| Parameters: |
|
-
|---|---|
| Returns: | Dictionary containing the country specific data of the callsign - |
-
| Return type: | dict - |
-
| Raises: |
|
-
Example
-The following code queries the the online Clublog API for the callsign “VK9XO” on a specific date.
->>> from pyhamtools import LookupLib
->>> from datetime import datetime
->>> import pytz
->>> my_lookuplib = LookupLib(lookuptype="clublogapi", apikey="myapikey")
->>> timestamp = datetime(year=1962, month=7, day=7, tzinfo=pytz.UTC)
->>> print my_lookuplib.lookup_callsign("VK9XO", timestamp)
-{
- 'country': 'CHRISTMAS ISLAND',
- 'longitude': -105.7,
- 'cqz': 29,
- 'adif': 35,
- 'latitude': -10.5,
- 'continent': 'OC'
-}
-Note
-This method is available for
-Returns lookup data of an ADIF Entity
-| Parameters: | entity (int) – ADIF identifier of country | -
|---|---|
| Returns: | Dictionary containing the country specific data | -
| Return type: | dict | -
| Raises: | KeyError – -No matching entity found | -
Example
-The following code queries the the Clublog XML database for the ADIF entity Turkmenistan, which has -the id 273.
->>> from pyhamtools import LookupLib
->>> my_lookuplib = LookupLib(lookuptype="clublogapi", apikey="myapikey")
->>> print my_lookuplib.lookup_entity(273)
-{
- 'deleted': False,
- 'country': 'TURKMENISTAN',
- 'longitude': -58.4,
- 'cqz': 17,
- 'prefix': 'EZ',
- 'latitude': 38.0,
- 'continent': 'AS'
-}
-Note
-This method is available for the following lookup type
-Returns lookup data of a Prefix
-| Parameters: |
|
-
|---|---|
| Returns: | Dictionary containing the country specific data of the Prefix - |
-
| Return type: | dict - |
-
| Raises: |
|
-
Example
-The following code shows how to obtain the information for the prefix “DH” from the countryfile.com -database (default database).
->>> from pyhamtools import LookupLib
->>> myLookupLib = LookupLib()
->>> print myLookupLib.lookup_prefix("DH")
-{
- 'adif': 230,
- 'country': 'Fed. Rep. of Germany',
- 'longitude': -10.0,
- 'cqz': 14,
- 'ituz': 28,
- 'latitude': 51.0,
- 'continent': 'EU'
-}
-Note
-This method is available for
-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: |
|
-
Example
-The following code checks the Clublog XML database if a CQ Zone exception exists for the callsign DP0GVN.
->>> from pyhamtools import LookupLib
->>> my_lookuplib = LookupLib(lookuptype="clublogxml", apikey="myapikey")
->>> print my_lookuplib.lookup_zone_exception("DP0GVN")
-38
-The prefix “DP” It is assigned to Germany, but the station is located in Antarctica, and therefore -in CQ Zone 38
-Note
-This method is available for
-| - p | ||
| - | - pyhamtools | - |
| - | - pyhamtools.callinfo | - |
| - | - pyhamtools.frequency | - |
| - | - pyhamtools.locator | - |
| - | - pyhamtools.lookuplib | - |
| - | - pyhamtools.qsl | - |
| - | - pyhamtools.utils | - |
- Please activate JavaScript to enable the search - functionality. -
-- From here you can search these documents. Enter your search - words into the box below and click "search". Note that the search - function will automatically search for all of the words. Pages - containing fewer words won't appear in the result list. -
- - -