s/ICap/IBaseCap and add constants
This commit is contained in:
parent
09d283052b
commit
45ffb0fe7d
11 changed files with 49 additions and 27 deletions
|
|
@ -21,7 +21,7 @@ if sys.version_info[:2] <= (2, 5):
|
|||
from weboob.tools.property import property
|
||||
|
||||
|
||||
from .cap import ICap
|
||||
from .base import IBaseCap
|
||||
|
||||
|
||||
__all__ = ['Account', 'AccountNotFound', 'ICapBank', 'Operation']
|
||||
|
|
@ -85,7 +85,7 @@ class Operation(object):
|
|||
self._amount = float(value)
|
||||
|
||||
|
||||
class ICapBank(ICap):
|
||||
class ICapBank(IBaseCap):
|
||||
def iter_accounts(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2010 Romain Bignon
|
||||
# Copyright(C) 2010 Christophe Benz
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -16,5 +16,26 @@
|
|||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
class ICap(object):
|
||||
__all__ = ['IBaseCap', 'NotLoaded', 'LoadingError']
|
||||
|
||||
|
||||
class NotLoadedMeta(type):
|
||||
def __unicode__(self):
|
||||
return u'Not loaded'
|
||||
|
||||
|
||||
class NotLoaded(object):
|
||||
__metaclass__ = NotLoadedMeta
|
||||
|
||||
|
||||
class LoadingErrorMeta(type):
|
||||
def __unicode__(self):
|
||||
return u'Loading error'
|
||||
|
||||
|
||||
class LoadingError(object):
|
||||
__metaclass__ = LoadingErrorMeta
|
||||
|
||||
|
||||
class IBaseCap(object):
|
||||
pass
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import datetime
|
||||
|
||||
from .cap import ICap
|
||||
from .base import IBaseCap
|
||||
|
||||
|
||||
__all__ = ['ChatException', 'ICapChat']
|
||||
|
|
@ -36,7 +36,7 @@ class ChatMessage(object):
|
|||
self.date = datetime.datetime.utcnow() if date is None else date
|
||||
|
||||
|
||||
class ICapChat(ICap):
|
||||
class ICapChat(IBaseCap):
|
||||
def iter_chat_messages(self, _id=None):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
from .cap import ICap
|
||||
from .base import IBaseCap
|
||||
from weboob.tools.ordereddict import OrderedDict
|
||||
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ class Contact(object):
|
|||
'profile': self.profile,
|
||||
}.iteritems()
|
||||
|
||||
class ICapContact(ICap):
|
||||
class ICapContact(IBaseCap):
|
||||
def iter_contacts(self, status=Contact.STATUS_ALL, ids=None):
|
||||
"""
|
||||
Iter contacts
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
from .cap import ICap
|
||||
from .base import IBaseCap
|
||||
|
||||
|
||||
__all__ = ['ICapDating']
|
||||
|
|
@ -45,7 +45,7 @@ class StatusField(object):
|
|||
self.flags = flags
|
||||
|
||||
|
||||
class ICapDating(ICap):
|
||||
class ICapDating(IBaseCap):
|
||||
def get_status(self):
|
||||
"""
|
||||
Get a list of fields
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
import datetime
|
||||
import time
|
||||
|
||||
from .cap import ICap
|
||||
from .base import IBaseCap
|
||||
|
||||
|
||||
__all__ = ['ICapMessages', 'ICapMessagesReply', 'Message']
|
||||
|
|
@ -83,7 +83,7 @@ class Message(object):
|
|||
self.thread_id, self.id, self.title, self.date, self.sender)
|
||||
return result.encode('utf-8')
|
||||
|
||||
class ICapMessages(ICap):
|
||||
class ICapMessages(IBaseCap):
|
||||
def iter_new_messages(self, thread=None):
|
||||
"""
|
||||
Iterates on new messages from last time this function has been called.
|
||||
|
|
@ -102,7 +102,7 @@ class ICapMessages(ICap):
|
|||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
class ICapMessagesReply(ICap):
|
||||
class ICapMessagesReply(IBaseCap):
|
||||
def post_reply(self, thread_id, reply_id, title, message):
|
||||
"""
|
||||
Post a reply.
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
from .cap import ICap
|
||||
from .base import IBaseCap
|
||||
|
||||
|
||||
__all__ = ['ICapTorrent', 'Torrent']
|
||||
|
|
@ -35,7 +35,7 @@ class Torrent(object):
|
|||
self.description = description
|
||||
|
||||
|
||||
class ICapTorrent(ICap):
|
||||
class ICapTorrent(IBaseCap):
|
||||
def iter_torrents(self, pattern):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@
|
|||
|
||||
from datetime import time
|
||||
|
||||
from .cap import ICap
|
||||
from .base import IBaseCap
|
||||
|
||||
|
||||
__all__ = ['Departure', 'ICapTravel', 'Station']
|
||||
|
||||
|
||||
class ICapTravel(ICap):
|
||||
class ICapTravel(IBaseCap):
|
||||
def iter_station_search(self, pattern):
|
||||
"""
|
||||
Iterates on search results of stations.
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
from .cap import ICap
|
||||
from .base import IBaseCap, LoadingError, NotLoaded
|
||||
|
||||
|
||||
__all__ = ['BaseVideo', 'ICapVideo']
|
||||
|
|
@ -36,17 +36,18 @@ class VideoThumbnail(object):
|
|||
def __iscomplete__(self):
|
||||
return self.data
|
||||
|
||||
|
||||
class BaseVideo(object):
|
||||
def __init__(self, _id, title=None, url=None, author=None, duration=None, date=None,
|
||||
rating=0.0, rating_max=0.0, thumbnail=None, thumbnail_url=None, nsfw=False):
|
||||
def __init__(self, _id, title=NotLoaded, url=NotLoaded, author=NotLoaded, duration=NotLoaded, date=NotLoaded,
|
||||
rating=NotLoaded, rating_max=NotLoaded, thumbnail=NotLoaded, thumbnail_url=NotLoaded, nsfw=False):
|
||||
self.id = unicode(_id)
|
||||
self.title = title
|
||||
self.url = url
|
||||
self.author = author
|
||||
self.duration = duration
|
||||
self.date = date
|
||||
self.rating = float(rating)
|
||||
self.rating_max = float(rating_max)
|
||||
self.rating = rating
|
||||
self.rating_max = rating_max
|
||||
self.thumbnail = thumbnail
|
||||
if thumbnail_url and not self.thumbnail:
|
||||
self.thumbnail = VideoThumbnail(thumbnail_url)
|
||||
|
|
@ -62,7 +63,7 @@ class BaseVideo(object):
|
|||
return self.id2url(self.id)
|
||||
|
||||
|
||||
class ICapVideo(ICap):
|
||||
class ICapVideo(IBaseCap):
|
||||
def iter_page_urls(self, mozaic_url):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
from .cap import ICap
|
||||
from .base import IBaseCap
|
||||
|
||||
|
||||
__all__ = ['City', 'CityNotFound', 'Current', 'Forecast', 'ICapWeather']
|
||||
|
|
@ -49,7 +49,7 @@ class CityNotFound(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class ICapWeather(ICap):
|
||||
class ICapWeather(IBaseCap):
|
||||
def iter_city_search(self, pattern):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import os
|
|||
import re
|
||||
import stat
|
||||
|
||||
from weboob.capabilities.cap import ICap
|
||||
from weboob.capabilities.base import IBaseCap
|
||||
from weboob.tools.backend import BaseBackend
|
||||
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ class Backend(object):
|
|||
|
||||
def iter_caps(self):
|
||||
for cap in self.klass.__bases__:
|
||||
if issubclass(cap, ICap) and cap != ICap:
|
||||
if issubclass(cap, IBaseCap) and cap != IBaseCap:
|
||||
yield cap
|
||||
|
||||
def has_caps(self, *caps):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue