fix some conversion warnings

This commit is contained in:
Romain Bignon 2012-04-03 22:40:49 +02:00
commit f2157c4cfb
6 changed files with 23 additions and 19 deletions

View file

@ -50,12 +50,12 @@ class IndexPage(BasePage):
rating_max += 1
video = ArteVideo(_id)
video.title = title
video.title = unicode(title)
video.rating = rating
video.rating_max = rating_max
thumb = self.parser.select(div, 'img[class=thumbnail]', 1)
video.thumbnail = Thumbnail('http://videos.arte.tv' + thumb.attrib['src'])
video.thumbnail = Thumbnail(u'http://videos.arte.tv' + thumb.attrib['src'])
try:
parts = self.parser.select(div, 'div.duration_thumbnail', 1).text.split(':')
@ -79,8 +79,8 @@ class VideoPage(BasePage):
def get_video(self, video=None, lang='fr', quality='hd'):
if not video:
video = ArteVideo(self.group_dict['id'])
video.title = self.get_title()
video.url = self.get_url(lang, quality)
video.title = unicode(self.get_title())
video.url = unicode(self.get_url(lang, quality))
video.set_empty_fields(NotAvailable)
return video

View file

@ -37,7 +37,7 @@ from weboob.tools.backend import BaseBackend, BackendConfig
from weboob.tools.browser import BrowserUnavailable
from weboob.tools.value import Value, ValuesDict, ValueBool, ValueBackendPassword
from weboob.tools.log import getLogger
from weboob.tools.misc import local2utc
from weboob.tools.misc import local2utc, to_unicode
from .contact import Contact
from .captcha import CaptchaError
@ -144,7 +144,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
continue
t = Thread(int(thread['member']['id']))
t.flags = Thread.IS_DISCUSSION
t.title = 'Discussion with %s' % thread['member']['pseudo']
t.title = u'Discussion with %s' % to_unicode(thread['member']['pseudo'])
yield t
def get_thread(self, id, contacts=None, get_profiles=False):
@ -215,10 +215,10 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
msg = Message(thread=thread,
id=int(time.strftime('%Y%m%d%H%M%S', parse_dt(mail['date']).timetuple())),
title=thread.title,
sender=my_name if int(mail['id_from']) == self.browser.my_id else mails['member']['pseudo'],
receivers=[my_name if int(mail['id_from']) != self.browser.my_id else mails['member']['pseudo']],
sender=to_unicode(my_name if int(mail['id_from']) == self.browser.my_id else mails['member']['pseudo']),
receivers=[to_unicode(my_name if int(mail['id_from']) != self.browser.my_id else mails['member']['pseudo'])],
date=parse_dt(mail['date']),
content=unescape(mail['message'] or '').strip(),
content=to_unicode(unescape(mail['message'] or '').strip()),
signature=signature,
children=[],
flags=flags)

View file

@ -92,7 +92,7 @@ class VideoPage(BasePage):
break
lastest_format = format
if not video.url and lastest_format is not None:
video.url = lastest_format.text
video.url = unicode(lastest_format.text)
day, month, year = map(int, infos.find('PUBLICATION').find('DATE').text.split('/'))
hour, minute, second = map(int, infos.find('PUBLICATION').find('HEURE').text.split(':'))

View file

@ -21,7 +21,7 @@
from decimal import Decimal
import re
from weboob.tools.browser import BasePage
from weboob.tools.browser import BasePage, BrokenPageError
from weboob.capabilities import NotAvailable
from weboob.capabilities.pricecomparison import Product, Shop, Price
@ -36,7 +36,7 @@ class IndexPage(BasePage):
label = li.find('label')
product = Product(input.attrib['value'])
product.name = label.text.strip()
product.name = unicode(label.text.strip())
if '&' in product.name:
# "E10 & SP95" produces a non-supported table.
@ -46,9 +46,13 @@ class IndexPage(BasePage):
class ComparisonResultsPage(BasePage):
def get_product_name(self):
div = self.parser.select(self.document.getroot(), 'div#moins_plus_ariane', 1)
m = re.match('Carburant : (\w+) | .*', div.text)
return m.group(1)
try:
div = self.parser.select(self.document.getroot(), 'div#moins_plus_ariane', 1)
except BrokenPageError:
return NotAvailable
else:
m = re.match('Carburant : (\w+) | .*', div.text)
return m.group(1)
def iter_results(self, product=None):
price = None
@ -64,8 +68,8 @@ class ComparisonResultsPage(BasePage):
price.currency = u''
shop = Shop(price.id)
shop.name = tds[2].text.strip()
shop.location = tds[0].text.strip()
shop.name = unicode(tds[2].text.strip())
shop.location = unicode(tds[0].text.strip())
price.shop = shop
price.set_empty_fields(NotAvailable)

View file

@ -93,7 +93,7 @@ class RoadmapPage(BasePage):
current_step['id'] = i
i += 1
current_step['start_time'] = self.parse_time(self.parser.select(tr, 'td.formattedHeureDepart p', 1).text.strip())
current_step['line'] = self.parser.select(tr, 'td.rechercheResultatColumnMode img')[-1].attrib['alt']
current_step['line'] = to_unicode(self.parser.select(tr, 'td.rechercheResultatColumnMode img')[-1].attrib['alt'])
current_step['departure'] = to_unicode(self.parser.select(tr, 'td.descDepart p strong', 1).text.strip())
current_step['duration'] = self.parse_duration(self.parser.select(tr, 'td.rechercheResultatVertAlign', 1).text.strip())
elif tr.attrib['class'] == 'trBasTroncon':

View file

@ -70,7 +70,7 @@ class YoutubeBackend(BaseBackend, ICapVideo, ICapCollection):
video.thumbnail = Thumbnail(to_unicode(entry.media.thumbnail[0].url.strip()))
if entry.author[0].name.text:
video.author = entry.author[0].name.text.strip()
video.author = to_unicode(entry.author[0].name.text.strip())
if entry.media.name:
video.author = to_unicode(entry.media.name.text.strip())
return video