Add missing unicode() calls to avoid ConversionWarning reports
Signed-off-by: Damien Cassou <damien.cassou@gmail.com> Signed-off-by: Romain Bignon <romain@symlink.me>
This commit is contained in:
parent
fbdf44e27a
commit
0a83341849
4 changed files with 15 additions and 15 deletions
|
|
@ -60,7 +60,7 @@ class PapBackend(BaseBackend, ICapHousing):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
for city in self.browser.search_geo(pattern):
|
for city in self.browser.search_geo(pattern):
|
||||||
c = City(city['id'])
|
c = City(city['id'])
|
||||||
c.name = city['name']
|
c.name = unicode(city['name'])
|
||||||
yield c
|
yield c
|
||||||
|
|
||||||
def fill_housing(self, housing, fields):
|
def fill_housing(self, housing, fields):
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ class SearchResultsPage(BasePage):
|
||||||
|
|
||||||
metro = div.cssselect('p.metro')
|
metro = div.cssselect('p.metro')
|
||||||
if len(metro) > 0:
|
if len(metro) > 0:
|
||||||
housing.station = metro[0].text.strip()
|
housing.station = unicode(metro[0].text.strip())
|
||||||
else:
|
else:
|
||||||
housing.station = NotAvailable
|
housing.station = NotAvailable
|
||||||
|
|
||||||
|
|
@ -76,7 +76,7 @@ class SearchResultsPage(BasePage):
|
||||||
b = p.findall('b')
|
b = p.findall('b')
|
||||||
if len(b) > 0:
|
if len(b) > 0:
|
||||||
housing.text = b[0].tail.strip()
|
housing.text = b[0].tail.strip()
|
||||||
housing.location = b[0].text
|
housing.location = unicode(b[0].text)
|
||||||
else:
|
else:
|
||||||
housing.text = p.text.strip()
|
housing.text = p.text.strip()
|
||||||
|
|
||||||
|
|
@ -108,7 +108,7 @@ class HousingPage(BasePage):
|
||||||
b = p.findall('b')
|
b = p.findall('b')
|
||||||
if len(b) > 0:
|
if len(b) > 0:
|
||||||
housing.text = b[0].tail.strip()
|
housing.text = b[0].tail.strip()
|
||||||
housing.location = b[0].text
|
housing.location = unicode(b[0].text)
|
||||||
if len(b) > 1:
|
if len(b) > 1:
|
||||||
housing.phone = b[1].text
|
housing.phone = b[1].text
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ class SeLogerBackend(BaseBackend, ICapHousing):
|
||||||
if not 'value' in city:
|
if not 'value' in city:
|
||||||
continue
|
continue
|
||||||
c = City(city['value'])
|
c = City(city['value'])
|
||||||
c.name = city['label']
|
c.name = unicode(city['label'])
|
||||||
yield c
|
yield c
|
||||||
|
|
||||||
def fill_housing(self, housing, fields):
|
def fill_housing(self, housing, fields):
|
||||||
|
|
|
||||||
|
|
@ -40,21 +40,21 @@ class SearchResultsPage(BasePage):
|
||||||
def iter_housings(self):
|
def iter_housings(self):
|
||||||
for a in self.document.getroot().xpath('//annonce'):
|
for a in self.document.getroot().xpath('//annonce'):
|
||||||
housing = Housing(a.find('idannonce').text)
|
housing = Housing(a.find('idannonce').text)
|
||||||
housing.title = a.find('titre').text
|
housing.title = unicode(a.find('titre').text)
|
||||||
housing.date = parse_date(a.find('dtfraicheur').text)
|
housing.date = parse_date(a.find('dtfraicheur').text)
|
||||||
housing.cost = Decimal(a.find('prix').text)
|
housing.cost = Decimal(a.find('prix').text)
|
||||||
housing.currency = u'€'
|
housing.currency = u'€'
|
||||||
housing.area = Decimal(a.find('surface').text)
|
housing.area = Decimal(a.find('surface').text)
|
||||||
housing.text = a.find('descriptif').text.strip()
|
housing.text = unicode(a.find('descriptif').text.strip())
|
||||||
housing.location = a.find('ville').text
|
housing.location = unicode(a.find('ville').text)
|
||||||
try:
|
try:
|
||||||
housing.station = a.find('proximite').text
|
housing.station = unicode(a.find('proximite').text)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
housing.station = NotAvailable
|
housing.station = NotAvailable
|
||||||
|
|
||||||
housing.photos = []
|
housing.photos = []
|
||||||
for photo in a.xpath('./photos/photo'):
|
for photo in a.xpath('./photos/photo'):
|
||||||
url = photo.find('stdurl').text
|
url = unicode(photo.find('stdurl').text)
|
||||||
housing.photos.append(HousingPhoto(url))
|
housing.photos.append(HousingPhoto(url))
|
||||||
|
|
||||||
yield housing
|
yield housing
|
||||||
|
|
@ -68,22 +68,22 @@ class HousingPage(BasePage):
|
||||||
if details.find('titre') is None:
|
if details.find('titre') is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
housing.title = details.find('titre').text
|
housing.title = unicode(details.find('titre').text)
|
||||||
housing.text = details.find('descriptif').text.strip()
|
housing.text = details.find('descriptif').text.strip()
|
||||||
housing.cost = Decimal(details.find('prix').text)
|
housing.cost = Decimal(details.find('prix').text)
|
||||||
housing.currency = u'€'
|
housing.currency = u'€'
|
||||||
housing.date = parse_date(details.find('dtfraicheur').text)
|
housing.date = parse_date(details.find('dtfraicheur').text)
|
||||||
housing.area = Decimal(details.find('surface').text)
|
housing.area = Decimal(details.find('surface').text)
|
||||||
housing.phone = details.find('contact').find('telephone').text
|
housing.phone = unicode(details.find('contact').find('telephone').text)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
housing.station = details.find('proximite').text
|
housing.station = unicode(details.find('proximite').text)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
housing.station = NotAvailable
|
housing.station = NotAvailable
|
||||||
|
|
||||||
housing.location = details.find('adresse').text
|
housing.location = details.find('adresse').text
|
||||||
if not housing.location and details.find('quartier') is not None:
|
if not housing.location and details.find('quartier') is not None:
|
||||||
housing.location = details.find('quartier').text
|
housing.location = unicode(details.find('quartier').text)
|
||||||
if not housing.location:
|
if not housing.location:
|
||||||
housing.location = NotAvailable
|
housing.location = NotAvailable
|
||||||
|
|
||||||
|
|
@ -93,7 +93,7 @@ class HousingPage(BasePage):
|
||||||
url = photo.find('bigurl').text
|
url = photo.find('bigurl').text
|
||||||
else:
|
else:
|
||||||
url = photo.find('stdurl').text
|
url = photo.find('stdurl').text
|
||||||
housing.photos.append(HousingPhoto(url))
|
housing.photos.append(HousingPhoto(unicode(url)))
|
||||||
|
|
||||||
housing.details = {}
|
housing.details = {}
|
||||||
for detail in details.xpath('./details/detail'):
|
for detail in details.xpath('./details/detail'):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue