From 195d437f8efffc7b8e5e4fd241db4da052fa06a3 Mon Sep 17 00:00:00 2001 From: "Tobias Wellnitz, DH1TW" Date: Sun, 28 Jan 2018 01:35:58 +0100 Subject: [PATCH] replaced regex with simple manipulation --- pyhamtools/callinfo.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/pyhamtools/callinfo.py b/pyhamtools/callinfo.py index ba03b82..d115047 100644 --- a/pyhamtools/callinfo.py +++ b/pyhamtools/callinfo.py @@ -96,26 +96,18 @@ class Callinfo(object): @staticmethod def check_if_mm(callsign): - if re.search("/MM$", callsign.upper()): - return True - else: - return False + check = callsign[-3:].upper() + return "/MM" in check @staticmethod def check_if_am(callsign): - if re.search("/AM$", callsign.upper()): - return True - else: - return False + check = callsign[-3:].upper() + return "/AM" in check @staticmethod def check_if_beacon(callsign): - if re.search("/B$", callsign.upper()): - return True - elif re.search("/BCN$", callsign.upper()): - return True - else: - return False + check = callsign[-4:].upper() + return "/B" in check or "/BCN" in check def _dismantle_callsign(self, callsign, timestamp=timestamp_now): """ try to identify the callsign's identity by analyzing it in the following order: