return s or ''
def s(s,n):
- return s or n
+ if n is not None:
+ return s or n.text
+ return s
class Address(object):
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