[weboob] [PATCH 1/1] Add missing unicode() calls to avoid ConversionWarning reports

Damien Cassou damien.cassou at gmail.com
Wed May 30 16:14:54 CEST 2012


Signed-off-by: Damien Cassou <damien.cassou at gmail.com>
---
 modules/pap/backend.py         |    2 +-
 modules/pap/pages.py           |    6 +++---
 modules/seloger/backend.py     |    2 +-
 modules/seloger/pages.py       |   16 ++++++++--------
 weboob/capabilities/housing.py |    2 +-
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/modules/pap/backend.py b/modules/pap/backend.py
index 75198e5..06b9d2c 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 f452ae9..af9ee49 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 0e82cc2..2125471 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 ed55be4..4d9cecc 100644
--- a/modules/seloger/pages.py
+++ b/modules/seloger/pages.py
@@ -40,15 +40,15 @@ 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
 
@@ -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
 
diff --git a/weboob/capabilities/housing.py b/weboob/capabilities/housing.py
index 11c1fd1..da498dc 100644
--- a/weboob/capabilities/housing.py
+++ b/weboob/capabilities/housing.py
@@ -34,7 +34,7 @@ class HousingPhoto(CapBaseObject):
 
     def __init__(self, url):
         CapBaseObject.__init__(self, url.split('/')[-1])
-        self.url = url
+        self.url = unicode(url)
 
     def __iscomplete__(self):
         return self.data
-- 
1.7.9.5




More information about the weboob mailing list