From 0a8334184954721f309823f73f19c7090aa99ae5 Mon Sep 17 00:00:00 2001 From: Damien Cassou Date: Wed, 30 May 2012 16:14:54 +0200 Subject: [PATCH] Add missing unicode() calls to avoid ConversionWarning reports Signed-off-by: Damien Cassou Signed-off-by: Romain Bignon --- modules/pap/backend.py | 2 +- modules/pap/pages.py | 6 +++--- modules/seloger/backend.py | 2 +- modules/seloger/pages.py | 20 ++++++++++---------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/pap/backend.py b/modules/pap/backend.py index 353aa427..13bffab3 100644 --- a/modules/pap/backend.py +++ b/modules/pap/backend.py @@ -60,7 +60,7 @@ class PapBackend(BaseBackend, ICapHousing): with self.browser: for city in self.browser.search_geo(pattern): c = City(city['id']) - c.name = city['name'] + c.name = unicode(city['name']) yield c def fill_housing(self, housing, fields): diff --git a/modules/pap/pages.py b/modules/pap/pages.py index f452ae91..af9ee492 100644 --- a/modules/pap/pages.py +++ b/modules/pap/pages.py @@ -68,7 +68,7 @@ class SearchResultsPage(BasePage): metro = div.cssselect('p.metro') if len(metro) > 0: - housing.station = metro[0].text.strip() + housing.station = unicode(metro[0].text.strip()) else: housing.station = NotAvailable @@ -76,7 +76,7 @@ class SearchResultsPage(BasePage): b = p.findall('b') if len(b) > 0: housing.text = b[0].tail.strip() - housing.location = b[0].text + housing.location = unicode(b[0].text) else: housing.text = p.text.strip() @@ -108,7 +108,7 @@ class HousingPage(BasePage): b = p.findall('b') if len(b) > 0: housing.text = b[0].tail.strip() - housing.location = b[0].text + housing.location = unicode(b[0].text) if len(b) > 1: housing.phone = b[1].text else: diff --git a/modules/seloger/backend.py b/modules/seloger/backend.py index 350f5be5..dcf09e9b 100644 --- a/modules/seloger/backend.py +++ b/modules/seloger/backend.py @@ -67,7 +67,7 @@ class SeLogerBackend(BaseBackend, ICapHousing): if not 'value' in city: continue c = City(city['value']) - c.name = city['label'] + c.name = unicode(city['label']) yield c def fill_housing(self, housing, fields): diff --git a/modules/seloger/pages.py b/modules/seloger/pages.py index ed55be4b..e005a387 100644 --- a/modules/seloger/pages.py +++ b/modules/seloger/pages.py @@ -40,21 +40,21 @@ class SearchResultsPage(BasePage): def iter_housings(self): for a in self.document.getroot().xpath('//annonce'): 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.cost = Decimal(a.find('prix').text) housing.currency = u'€' housing.area = Decimal(a.find('surface').text) - housing.text = a.find('descriptif').text.strip() - housing.location = a.find('ville').text + housing.text = unicode(a.find('descriptif').text.strip()) + housing.location = unicode(a.find('ville').text) try: - housing.station = a.find('proximite').text + housing.station = unicode(a.find('proximite').text) except AttributeError: housing.station = NotAvailable housing.photos = [] for photo in a.xpath('./photos/photo'): - url = photo.find('stdurl').text + url = unicode(photo.find('stdurl').text) housing.photos.append(HousingPhoto(url)) yield housing @@ -68,22 +68,22 @@ class HousingPage(BasePage): if details.find('titre') is None: return None - housing.title = details.find('titre').text + housing.title = unicode(details.find('titre').text) housing.text = details.find('descriptif').text.strip() housing.cost = Decimal(details.find('prix').text) housing.currency = u'€' housing.date = parse_date(details.find('dtfraicheur').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: - housing.station = details.find('proximite').text + housing.station = unicode(details.find('proximite').text) except AttributeError: housing.station = NotAvailable housing.location = details.find('adresse').text 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: housing.location = NotAvailable @@ -93,7 +93,7 @@ class HousingPage(BasePage): url = photo.find('bigurl').text else: url = photo.find('stdurl').text - housing.photos.append(HousingPhoto(url)) + housing.photos.append(HousingPhoto(unicode(url))) housing.details = {} for detail in details.xpath('./details/detail'):