diff --git a/utils/helperutils.py b/utils/helperutils.py index 8a648d2..55a1711 100644 --- a/utils/helperutils.py +++ b/utils/helperutils.py @@ -1,10 +1,10 @@ from datetime import datetime, timedelta def log(value): - - try: - print(str(datetime.now()) + ' ' + value.encode("utf-8")) - except UnicodeEncodeError: - print(str(datetime.now()) + ' print error') + print(str(datetime.now()) + ' ' + value) + # try: + # print(str(datetime.now()) + ' ' + value.encode("utf-8")) + # except: + # print(str(datetime.now()) + ' print error') #print(u' '.join(( str(datetime.now()), value)).encode('utf-8').strip()) \ No newline at end of file diff --git a/utils/locationutils.py b/utils/locationutils.py index 5e15001..a6b945b 100644 --- a/utils/locationutils.py +++ b/utils/locationutils.py @@ -40,6 +40,9 @@ def getGeoLocationByCity(city = "", countrycode: Countrycode = Countrycode.NL ): geonames = getLocationArray(countrycode) + city = re.sub(u"(\u2018|\u2019)", "'", city) #replaces single quotes chars by ' + + # log('cityname and city: ' + cityname + " , " + city) #first tries name with 'gemeente as prefix' @@ -65,7 +68,6 @@ def getGeoLocationByCity(city = "", countrycode: Countrycode = Countrycode.NL ): if (geo): return geo; #removes everything between () and then removes the leading and trailing spaces; - log('name before regex ' + city) #city = re.sub('/\([^()]*\)/g', '', city) city = re.sub("[\(].*?[\)]", "", city) @@ -77,7 +79,6 @@ def getGeoLocationByCity(city = "", countrycode: Countrycode = Countrycode.NL ): #print('without anything between ()' + repr( geo)) if (geo): return geo; - #also tries in the alternatenames geo = list(filter(lambda g: inAlternatenames(g.alternatenames, city), geonames)) if(geo): geo = geo[0]