From e4d933a55b831cc8c887ddb71acc386584355403 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Fri, 1 Dec 2017 15:52:50 +0100 Subject: [PATCH] refacto: rmoved prints and added return in case phone number can't be parsed --- geo_helper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/geo_helper.py b/geo_helper.py index ca1c83f..0a7f2da 100644 --- a/geo_helper.py +++ b/geo_helper.py @@ -109,14 +109,15 @@ class Geo_helper: def getCoordFromPhoneAndPublish(self, phoneNumber, categ): try: - print('function accessed') rep = phonenumbers.parse(phoneNumber, None) if not (phonenumbers.is_valid_number(rep) or phonenumbers.is_possible_number(rep)): print("Phone number not valid") + return country_name = geocoder.country_name_for_number(rep, "en") country_code = self.country_to_iso[country_name] if country_code is None: print("Non matching ISO_CODE") + return coord = self.country_code_to_coord[country_code.lower()] # countrycode is in upper case coord_dic = {'lat': coord['lat'], 'lon': coord['long']} @@ -139,7 +140,6 @@ class Geo_helper: "cityName": "", "regionCode": country_code, } - print(to_send) self.serv_coord.publish(self.CHANNELDISP, json.dumps(to_send)) except phonenumbers.NumberParseException: print("Can't resolve phone number country")