From 01284a5ae862c791d76b4b6b18fd1cb6c64cb728 Mon Sep 17 00:00:00 2001 From: "Tobias Wellnitz, DH1TW" Date: Mon, 26 Dec 2022 21:13:13 +0100 Subject: [PATCH] callinfo: recognize callsigns with digits in the suffix --- docs/source/changelog.rst | 8 ++++++++ pyhamtools/callinfo.py | 2 +- pyhamtools/version.py | 2 +- test/test_callinfo.py | 21 +++++++++++++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 868f811..849eb6e 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -1,6 +1,14 @@ Changelog --------- +PyHamtools 0.8.5 +================ + +26. December 2022 + +* refined regex for decoding callsigns. In particular to better recognize callsigns with one or more digits in the suffix (e.g. TI5N5BEK, DP44N44T) + + PyHamtools 0.8.4 ================ diff --git a/pyhamtools/callinfo.py b/pyhamtools/callinfo.py index 27c19fd..0128d43 100644 --- a/pyhamtools/callinfo.py +++ b/pyhamtools/callinfo.py @@ -205,7 +205,7 @@ class Callinfo(object): return self._iterate_prefix(callsign, timestamp) # regular callsigns, without prefix or appendix - elif re.match('^[\\d]{0,1}[A-Z]{1,2}\\d([A-Z]{1,4}|\\d{3,3}|\\d{1,3}[A-Z])[A-Z]{0,5}$', callsign): + elif re.match('^[\\d]{0,1}[A-Z]{1,2}\\d{1,2}[A-Z]{1,2}([A-Z]{1,4}|\\d{1,3})[A-Z]{0,5}$', callsign): return self._iterate_prefix(callsign, timestamp) # callsigns with prefixes (xxx/callsign) diff --git a/pyhamtools/version.py b/pyhamtools/version.py index b0ba366..f694b15 100644 --- a/pyhamtools/version.py +++ b/pyhamtools/version.py @@ -1,3 +1,3 @@ -VERSION = (0, 8, 4) +VERSION = (0, 8, 5) __release__ = ''.join(['-.'[type(x) == int]+str(x) for x in VERSION])[1:] __version__ = '.'.join((str(VERSION[0]), str(VERSION[1]))) diff --git a/test/test_callinfo.py b/test/test_callinfo.py index c023fb8..aa974d7 100644 --- a/test/test_callinfo.py +++ b/test/test_callinfo.py @@ -103,6 +103,24 @@ response_prefix_VK9GMW_clublog = { u'longitude': 155.8 } +response_prefix_8J1H90T_clublog = { + u'adif': 339, + u'continent': u'AS', + u'country': u'JAPAN', + u'cqz': 25, + u'latitude': 35.7, + u'longitude': 139.8 +} + +response_prefix_TI5N5BEK_clublog = { + u'adif': 308, + u'continent': u'NA', + u'country': u'COSTA RICA', + u'cqz': 7, + u'latitude': 9.9, + u'longitude': -84.0 +} + response_callsign_exceptions_7N1PRD_0_clublog = { u'adif': 339, u'continent': u'AS', @@ -231,12 +249,15 @@ class Test_callinfo_methods: assert fix_callinfo._dismantle_callsign("DH1TW/M") == response_prefix_DH_clublog assert fix_callinfo._dismantle_callsign("DH1TW/B")[const.BEACON] assert fix_callinfo._dismantle_callsign("DH1TW") == response_prefix_DH_clublog + assert fix_callinfo._dismantle_callsign("DP44N44T") == response_prefix_DH_clublog assert fix_callinfo._dismantle_callsign("DL/HC2AO") == response_prefix_DH_clublog assert fix_callinfo._dismantle_callsign("9H5A/C6A") == response_prefix_C6A_clublog assert fix_callinfo._dismantle_callsign("C6A/9H5A") == response_prefix_C6A_clublog assert fix_callinfo._dismantle_callsign("DH1TW/UNI") == response_prefix_DH_clublog assert fix_callinfo._dismantle_callsign("DH1TW/BUX") == response_prefix_DH_clublog assert fix_callinfo._dismantle_callsign("DH1TW/NOT") == response_prefix_DH_clublog + assert fix_callinfo._dismantle_callsign("8J1H90T") == response_prefix_8J1H90T_clublog + assert fix_callinfo._dismantle_callsign("TI5N5BEK") == response_prefix_TI5N5BEK_clublog assert fix_callinfo._dismantle_callsign("VK9DLX/NOT") == response_prefix_VK9DLX_clublog assert fix_callinfo._dismantle_callsign("7QAA") == response_callsign_exceptions_7QAA_clublog assert fix_callinfo._dismantle_callsign("7N1PRD/0") == response_callsign_exceptions_7N1PRD_0_clublog