If nominatim data does not exists (eg postcode is not there, but boundary or vice
versa) then the old code failed with NoneType object.
This addresses this but is not optimal.
Current tests works with the sites, so using this solution for now.
return s or ''
def s(s,n):
return s or ''
def s(s,n):
+ if n is not None:
+ return s or n.text
+ return s
places = int(root.xpath('count(//place[@place_id])'))
if places == 1:
place = root.find("place")
places = int(root.xpath('count(//place[@place_id])'))
if places == 1:
place = root.find("place")
- self.postcode = s(self.postcode,place.find("boundary").text)
- self.city = s(self.city,place.find("city").text)
- self.country = s(self.country,place.find("country").text)
- self.country_code = s(self.country_code,place.find("country_code").text)
+# print etree.tostring(place,encoding='UTF-8',pretty_print=True)
+ self.postcode = s(self.postcode,place.find("postcode"))
+ self.city = s(self.city,place.find("city"))
+ self.country = s(self.country,place.find("country"))
+ self.country_code = s(self.country_code,place.find("country_code"))
self.coord=Coord(place.get("lat"),place.get("lon"))
return
self.coord=Coord(place.get("lat"),place.get("lon"))
return