use snake case for to_unicode
This commit is contained in:
parent
22cb3e1cbd
commit
51239167d3
3 changed files with 16 additions and 16 deletions
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
from datetime import datetime, date, time
|
from datetime import datetime, date, time
|
||||||
from weboob.tools.browser import BaseBrowser
|
from weboob.tools.browser import BaseBrowser
|
||||||
from weboob.tools.misc import toUnicode
|
from weboob.tools.misc import to_unicode
|
||||||
|
|
||||||
class CanalTP(BaseBrowser):
|
class CanalTP(BaseBrowser):
|
||||||
DOMAIN = 'widget.canaltp.fr'
|
DOMAIN = 'widget.canaltp.fr'
|
||||||
|
|
@ -36,7 +36,7 @@ class CanalTP(BaseBrowser):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
yield _id, toUnicode(name)
|
yield _id, to_unicode(name)
|
||||||
|
|
||||||
def iter_station_departures(self, station_id, arrival_id=None):
|
def iter_station_departures(self, station_id, arrival_id=None):
|
||||||
result = self.openurl(u"http://widget.canaltp.fr/Prochains_departs_15122009/dev/index.php?gare=%s" % unicode(station_id)).read()
|
result = self.openurl(u"http://widget.canaltp.fr/Prochains_departs_15122009/dev/index.php?gare=%s" % unicode(station_id)).read()
|
||||||
|
|
@ -48,12 +48,12 @@ class CanalTP(BaseBrowser):
|
||||||
departure = value
|
departure = value
|
||||||
elif key.startswith('ligne'):
|
elif key.startswith('ligne'):
|
||||||
_type, unknown, _time, arrival, served, late, late_reason = value.split(';', 6)
|
_type, unknown, _time, arrival, served, late, late_reason = value.split(';', 6)
|
||||||
yield {'type': toUnicode(_type),
|
yield {'type': to_unicode(_type),
|
||||||
'time': datetime.combine(date.today(), time(*[int(x) for x in _time.split(':')])),
|
'time': datetime.combine(date.today(), time(*[int(x) for x in _time.split(':')])),
|
||||||
'departure': toUnicode(departure),
|
'departure': to_unicode(departure),
|
||||||
'arrival': toUnicode(arrival).strip(),
|
'arrival': to_unicode(arrival).strip(),
|
||||||
'late': late and time(0, int(late.split()[0])) or time(),
|
'late': late and time(0, int(late.split()[0])) or time(),
|
||||||
'late_reason': toUnicode(late_reason).replace('\n', '').strip()}
|
'late_reason': to_unicode(late_reason).replace('\n', '').strip()}
|
||||||
|
|
||||||
def home(self):
|
def home(self):
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ from datetime import datetime, date, time
|
||||||
import HTMLParser
|
import HTMLParser
|
||||||
|
|
||||||
from weboob.tools.browser import BaseBrowser
|
from weboob.tools.browser import BaseBrowser
|
||||||
from weboob.tools.misc import toUnicode
|
from weboob.tools.misc import to_unicode
|
||||||
|
|
||||||
from .pages.route import RoutePage
|
from .pages.route import RoutePage
|
||||||
|
|
||||||
|
|
@ -138,13 +138,13 @@ class Transilien(BaseBrowser):
|
||||||
_time = None
|
_time = None
|
||||||
_late_reason = route.time
|
_late_reason = route.time
|
||||||
else:
|
else:
|
||||||
yield {'type': toUnicode(route.code_mission),
|
yield {'type': to_unicode(route.code_mission),
|
||||||
'time': _time,
|
'time': _time,
|
||||||
'departure': toUnicode(station_id),
|
'departure': to_unicode(station_id),
|
||||||
'arrival': toUnicode(route.destination),
|
'arrival': to_unicode(route.destination),
|
||||||
'late': time(),
|
'late': time(),
|
||||||
'late_reason': _late_reason,
|
'late_reason': _late_reason,
|
||||||
'plateform': toUnicode(route.platform)}
|
'plateform': to_unicode(route.platform)}
|
||||||
|
|
||||||
def home(self):
|
def home(self):
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -22,16 +22,16 @@ import traceback
|
||||||
import types
|
import types
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['toUnicode', 'local2utc', 'html2text', 'get_backtrace', 'iter_fields']
|
__all__ = ['to_unicode', 'local2utc', 'html2text', 'get_backtrace', 'iter_fields']
|
||||||
|
|
||||||
|
|
||||||
def toUnicode(text):
|
def to_unicode(text):
|
||||||
r"""
|
r"""
|
||||||
>>> toUnicode('ascii')
|
>>> to_unicode('ascii')
|
||||||
u'ascii'
|
u'ascii'
|
||||||
>>> toUnicode(u'utf\xe9'.encode('UTF-8'))
|
>>> to_unicode(u'utf\xe9'.encode('UTF-8'))
|
||||||
u'utf\xe9'
|
u'utf\xe9'
|
||||||
>>> toUnicode(u'unicode')
|
>>> to_unicode(u'unicode')
|
||||||
u'unicode'
|
u'unicode'
|
||||||
"""
|
"""
|
||||||
if isinstance(text, unicode):
|
if isinstance(text, unicode):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue