moved ICapDating.get_status() and ICapMessagesPost.get_status() into ICapAccount.get_account_status()
This commit is contained in:
parent
368ef37d5b
commit
c83c923e3d
8 changed files with 72 additions and 64 deletions
|
|
@ -25,9 +25,9 @@ from dateutil import tz
|
|||
from weboob.capabilities.base import NotLoaded
|
||||
from weboob.capabilities.chat import ICapChat
|
||||
from weboob.capabilities.messages import ICapMessages, ICapMessagesPost, Message, Thread
|
||||
from weboob.capabilities.dating import ICapDating, StatusField, OptimizationNotFound
|
||||
from weboob.capabilities.dating import ICapDating, OptimizationNotFound
|
||||
from weboob.capabilities.contact import ICapContact, Contact, ContactPhoto, ProfileNode, Query, QueryError
|
||||
from weboob.capabilities.account import ICapAccount
|
||||
from weboob.capabilities.account import ICapAccount, StatusField
|
||||
from weboob.tools.backend import BaseBackend
|
||||
from weboob.tools.browser import BrowserUnavailable
|
||||
from weboob.tools.value import Value, ValuesDict, ValueBool
|
||||
|
|
@ -90,17 +90,6 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
|
|||
self.add_optimization('PRIORITY_CONNECTION', PriorityConnection(self.weboob.scheduler, self.storage, self.browser))
|
||||
self.add_optimization('QUERIES_QUEUE', QueriesQueue(self.weboob.scheduler, self.storage, self.browser))
|
||||
|
||||
def get_status(self):
|
||||
with self.browser:
|
||||
try:
|
||||
return (
|
||||
StatusField('myname', 'My name', self.browser.get_my_name()),
|
||||
StatusField('score', 'Score', self.browser.score()),
|
||||
StatusField('avcharms', 'Available charms', self.browser.nb_available_charms()),
|
||||
)
|
||||
except AdopteWait:
|
||||
return (StatusField('notice', '', u'<h3>You are currently waiting 1am to be able to connect with this account</h3>', StatusField.FIELD_HTML|StatusField.FIELD_TEXT))
|
||||
|
||||
# ---- ICapMessages methods ---------------------
|
||||
|
||||
def fill_thread(self, thread, fields):
|
||||
|
|
@ -495,6 +484,18 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
|
|||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_account_status(self):
|
||||
with self.browser:
|
||||
try:
|
||||
return (
|
||||
StatusField('myname', 'My name', self.browser.get_my_name()),
|
||||
StatusField('score', 'Score', self.browser.score()),
|
||||
StatusField('avcharms', 'Available charms', self.browser.nb_available_charms()),
|
||||
StatusField('godchilds', 'Number of godchilds', self.browser.nb_godchilds()),
|
||||
)
|
||||
except AdopteWait:
|
||||
return (StatusField('notice', '', u'<h3>You are currently waiting 1am to be able to connect with this account</h3>', StatusField.FIELD_HTML|StatusField.FIELD_TEXT))
|
||||
|
||||
OBJECTS = {Thread: fill_thread,
|
||||
Contact: fill_contact,
|
||||
ContactPhoto: fill_photo
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
from __future__ import with_statement
|
||||
|
||||
from weboob.capabilities.messages import CantSendMessage, ICapMessagesPost, StatusField
|
||||
from weboob.capabilities.messages import CantSendMessage, ICapMessages, ICapMessagesPost
|
||||
from weboob.capabilities.account import ICapAccount, StatusField
|
||||
from weboob.tools.backend import BaseBackend
|
||||
from weboob.tools.value import ValuesDict, Value
|
||||
|
||||
|
|
@ -28,7 +29,7 @@ from .browser import SfrBrowser
|
|||
__all__ = ['SfrBackend']
|
||||
|
||||
|
||||
class SfrBackend(BaseBackend, ICapMessagesPost):
|
||||
class SfrBackend(BaseBackend, ICapAccount, ICapMessages, ICapMessagesPost):
|
||||
NAME = 'sfr'
|
||||
MAINTAINER = 'Christophe Benz'
|
||||
EMAIL = 'christophe.benz@gmail.com'
|
||||
|
|
@ -38,13 +39,14 @@ class SfrBackend(BaseBackend, ICapMessagesPost):
|
|||
CONFIG = ValuesDict(Value('login', label='Login'),
|
||||
Value('password', label='Password', masked=True))
|
||||
BROWSER = SfrBrowser
|
||||
ACCOUNT_REGISTER_PROPERTIES = None
|
||||
|
||||
def create_default_browser(self):
|
||||
return self.create_browser(self.config['login'], self.config['password'])
|
||||
|
||||
# ICapMessagesPost methods
|
||||
|
||||
def get_status(self):
|
||||
def get_account_status(self):
|
||||
with self.browser:
|
||||
return (StatusField('nb_remaining_free_sms', 'Number of remaining free SMS',
|
||||
self.browser.get_nb_remaining_free_sms()),)
|
||||
|
|
@ -53,4 +55,4 @@ class SfrBackend(BaseBackend, ICapMessagesPost):
|
|||
if not message.content.strip():
|
||||
raise CantSendMessage(u'Message content is empty.')
|
||||
with self.browser:
|
||||
self.browser.post_message(message)
|
||||
self.browser.post_message(message)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue