pax_global_header 0000666 0000000 0000000 00000000064 11713545762 0014525 g ustar 00root root 0000000 0000000 52 comment=7e000895908c0941e58c7311b68234a4b827e76c
woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/ 0000775 0000000 0000000 00000000000 11713545762 0023325 5 ustar 00root root 0000000 0000000 woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/ 0000775 0000000 0000000 00000000000 11713545762 0024602 5 ustar 00root root 0000000 0000000 woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities/ 0000775 0000000 0000000 00000000000 11713545762 0027233 5 ustar 00root root 0000000 0000000 __init__.py 0000664 0000000 0000000 00000000001 11713545762 0031254 0 ustar 00root root 0000000 0000000 woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities
woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities/account.py0000664 0000000 0000000 00000004726 11713545762 0031252 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Romain Bignon
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
from .base import IBaseCap, CapBaseObject
__all__ = ['ICapAccount']
class AccountRegisterError(Exception):
pass
class Account(CapBaseObject):
def __init__(self, id=None):
CapBaseObject.__init__(self, id)
self.add_field('login', basestring)
self.add_field('password', basestring)
self.add_field('properties', dict)
class StatusField(object):
FIELD_TEXT = 0x001 # the value is a long text
FIELD_HTML = 0x002 # the value is HTML formated
def __init__(self, key, label, value, flags=0):
self.key = key
self.label = label
self.value = value
self.flags = flags
class ICapAccount(IBaseCap):
# This class constant may be a list of Value* objects. If the value remains
# None, weboob considers that register_account() isn't supported.
ACCOUNT_REGISTER_PROPERTIES = None
@staticmethod
def register_account(account):
"""
Register an account on website
This is a static method, it would be called even if the backend is
instancied.
@param account an Account object which describe the account to create
"""
raise NotImplementedError()
def confirm_account(self, mail):
"""
From an email go to the confirm link.
"""
raise NotImplementedError()
def get_account(self):
"""
Get the current account.
"""
raise NotImplementedError()
def update_account(self, account):
"""
Update the current account.
"""
raise NotImplementedError()
def get_account_status(self):
"""
Get status of the current account.
@return a list of fields
"""
raise NotImplementedError()
woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities/bank.py 0000664 0000000 0000000 00000006776 11713545762 0030540 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Romain Bignon
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
from datetime import datetime, date
from .base import CapBaseObject
from .collection import ICapCollection, CollectionNotFound
__all__ = ['Account', 'AccountNotFound', 'TransferError', 'ICapBank',
'Operation']
class AccountNotFound(Exception):
def __init__(self, msg=None):
if msg is None:
msg = 'Account not found'
Exception.__init__(self, msg)
class TransferError(Exception):
pass
class Recipient(CapBaseObject):
def __init__(self):
CapBaseObject.__init__(self, 0)
self.add_field('label', basestring)
class Account(Recipient):
def __init__(self):
Recipient.__init__(self)
self.add_field('balance', float)
self.add_field('coming', float)
self.link_id = None
def __repr__(self):
return u"" % (self.id, self.label)
class Operation(CapBaseObject):
def __init__(self, id):
CapBaseObject.__init__(self, id)
self.add_field('date', (basestring, datetime, date))
self.add_field('category', unicode)
self.add_field('label', unicode)
self.add_field('amount', float)
def __repr__(self):
return "" % (self.date,
self.label, self.amount)
class Transfer(CapBaseObject):
def __init__(self, id):
CapBaseObject.__init__(self, id)
self.add_field('amount', float)
self.add_field('date', (basestring, datetime, date))
self.add_field('origin', (int, long, basestring))
self.add_field('recipient', (int, long, basestring))
class ICapBank(ICapCollection):
def iter_resources(self, objs, split_path):
if Account in objs:
if len(split_path) > 0:
raise CollectionNotFound(split_path)
return self.iter_accounts()
def iter_accounts(self):
raise NotImplementedError()
def get_account(self, _id):
raise NotImplementedError()
def iter_operations(self, account):
raise NotImplementedError()
def iter_history(self, account):
raise NotImplementedError()
def iter_transfer_recipients(self, account):
"""
Iter recipients availables for a transfer from a specific account.
@param account [Account] account which initiate the transfer
@return [iter(Recipient)]
"""
raise NotImplementedError()
def transfer(self, account, recipient, amount, reason=None):
"""
Make a transfer from an account to a recipient.
@param account [Account] account to take money
@param recipient [Recipient] account to send money
@param amount [float] amount
@param reason [str] reason of transfer
@return [Transfer] a Transfer object
"""
raise NotImplementedError()
woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities/base.py 0000664 0000000 0000000 00000010666 11713545762 0030530 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Christophe Benz, Romain Bignon
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
from weboob.tools.misc import iter_fields
__all__ = ['FieldNotFound', 'IBaseCap', 'NotAvailable', 'NotLoaded',
'CapBaseObject']
class FieldNotFound(Exception):
def __init__(self, obj, field):
Exception.__init__(self,
u'Field "%s" not found for object %s' % (field, obj))
class NotAvailableMeta(type):
def __str__(self):
return unicode(self).decode('utf-8')
def __unicode__(self):
return u'Not available'
def __nonzero__(self):
return False
class NotAvailable(object):
__metaclass__ = NotAvailableMeta
class NotLoadedMeta(type):
def __str__(self):
return unicode(self).decode('utf-8')
def __unicode__(self):
return u'Not loaded'
def __nonzero__(self):
return False
class NotLoaded(object):
__metaclass__ = NotLoadedMeta
class IBaseCap(object):
pass
class CapBaseObject(object):
FIELDS = None
_attribs = None
def __init__(self, id, backend=None):
self.id = id
self.backend = backend
def add_field(self, name, type, value=NotLoaded):
"""
Add a field in list, which needs to be of type @type.
@param name [str] name of field
@param type [class] type accepted (can be a tuple of types)
@param value [object] value set to attribute (default is NotLoaded)
"""
if not isinstance(self.FIELDS, list):
self.FIELDS = []
self.FIELDS.append(name)
if self._attribs is None:
self._attribs = {}
self._attribs[name] = self._AttribValue(type, value)
def __iscomplete__(self):
"""
Return True if the object is completed.
It is usefull when the object is a field of an other object which is
going to be filled.
The default behavior is to iter on fields (with iter_fields) and if
a field is NotLoaded, return False.
"""
for key, value in self.iter_fields():
if value is NotLoaded:
return False
return True
def iter_fields(self):
"""
Iterate on the FIELDS keys and values.
Can be overloaded to iterate on other things.
@return [iter(key,value)] iterator on key, value
"""
if self.FIELDS is None:
yield 'id', self.id
for key, value in iter_fields(self):
if key not in ('id', 'backend','FIELDS'):
yield key, value
else:
yield 'id', self.id
for attrstr in self.FIELDS:
yield attrstr, getattr(self, attrstr)
def __eq__(self, obj):
if isinstance(obj, CapBaseObject):
return self.backend == obj.backend and self.id == obj.id
else:
return False
class _AttribValue(object):
def __init__(self, type, value):
self.type = type
self.value = value
def __getattr__(self, name):
if self._attribs is not None and name in self._attribs:
return self._attribs[name].value
else:
raise AttributeError, "'%s' object has no attribute '%s'" % (
self.__class__.__name__, name)
def __setattr__(self, name, value):
try:
attr = (self._attribs or {})[name]
except KeyError:
object.__setattr__(self, name, value)
else:
if not isinstance(value, attr.type) and \
value is not NotLoaded and \
value is not NotAvailable and \
value is not None:
raise ValueError(
'Value for "%s" needs to be of type %r, not %r' % (
name, attr.type, type(value)))
attr.value = value
bugtracker.py 0000664 0000000 0000000 00000013627 11713545762 0031670 0 ustar 00root root 0000000 0000000 woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities # -*- coding: utf-8 -*-
# Copyright(C) 2011 Romain Bignon
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
from datetime import datetime, timedelta
from .base import IBaseCap, CapBaseObject
__all__ = ['ICapBugTracker']
class IssueError(Exception):
pass
class Project(CapBaseObject):
def __init__(self, id, name):
CapBaseObject.__init__(self, id)
self.add_field('name', unicode, name)
self.add_field('members', list)
self.add_field('versions', list)
self.add_field('categories', list)
self.add_field('statuses', list)
def __repr__(self):
return '' % self.name
def find_user(self, id, name):
for user in self.members:
if user.id == id:
return user
if name is None:
return None
return User(id, name)
def find_version(self, id, name):
for version in self.versions:
if version.id == id:
return version
if name is None:
return None
return Version(id, name)
def find_status(self, name):
for status in self.statuses:
if status.name == name:
return status
if name is None:
return None
return None
class User(CapBaseObject):
def __init__(self, id, name):
CapBaseObject.__init__(self, id)
self.add_field('name', unicode, name)
def __repr__(self):
return '' % self.name
class Version(CapBaseObject):
def __init__(self, id, name):
CapBaseObject.__init__(self, id)
self.add_field('name', unicode, name)
def __repr__(self):
return '' % self.name
class Status(CapBaseObject):
(VALUE_NEW,
VALUE_PROGRESS,
VALUE_RESOLVED,
VALUE_REJECTED) = range(4)
def __init__(self, id, name, value):
CapBaseObject.__init__(self, id)
self.add_field('name', unicode, name)
self.add_field('value', int, value)
def __repr__(self):
return '' % self.name
class Attachment(CapBaseObject):
def __init__(self, id):
CapBaseObject.__init__(self, id)
self.add_field('filename', basestring)
self.add_field('url', basestring)
def __repr__(self):
return '' % self.filename
class Change(CapBaseObject):
def __init__(self, id):
CapBaseObject.__init__(self, id)
self.add_field('field', unicode)
self.add_field('last', unicode)
self.add_field('new', unicode)
class Update(CapBaseObject):
def __init__(self, id):
CapBaseObject.__init__(self, id)
self.add_field('author', User)
self.add_field('date', datetime)
self.add_field('hours', timedelta)
self.add_field('message', unicode)
self.add_field('attachments', (list,tuple)) # Attachment
self.add_field('changes', (list,tuple)) # Change
def __repr__(self):
return '' % self.id
class Issue(CapBaseObject):
def __init__(self, id):
CapBaseObject.__init__(self, id)
self.add_field('project', Project)
self.add_field('title', unicode)
self.add_field('body', unicode)
self.add_field('creation', datetime)
self.add_field('updated', datetime)
self.add_field('attachments', (list,tuple))
self.add_field('history', (list,tuple))
self.add_field('author', User)
self.add_field('assignee', User)
self.add_field('category', unicode)
self.add_field('version', Version)
self.add_field('status', Status)
class Query(CapBaseObject):
def __init__(self):
CapBaseObject.__init__(self, '')
self.add_field('project', unicode)
self.add_field('title', unicode)
self.add_field('author', unicode)
self.add_field('assignee', unicode)
self.add_field('version', unicode)
self.add_field('category', unicode)
self.add_field('status', unicode)
class ICapBugTracker(IBaseCap):
def iter_issues(self, query):
"""
Iter issues with optionnal patterns.
@param query [Query]
@return [iter(Issue)] issues
"""
raise NotImplementedError()
def get_issue(self, id):
"""
Get an issue from its ID.
@return Issue
"""
raise NotImplementedError()
def create_issue(self, project):
"""
Create an empty issue on the given project.
@return [Issue] the created issue.
"""
raise NotImplementedError()
def post_issue(self, issue):
"""
Post an issue to create or update it.
"""
raise NotImplementedError()
def update_issue(self, issue, update):
"""
Add an update to an issue.
@param issue [id,Issue] issue or id of issue
@param update [Update] an Update object
"""
raise NotImplementedError()
def remove_issue(self, issue):
"""
Remove an issue.
"""
raise NotImplementedError()
def iter_projects(self):
"""
Iter projects.
@return [iter(Project)] projects
"""
raise NotImplementedError()
def get_project(self, id):
"""
Get a project from its ID.
@return [Project]
"""
raise NotImplementedError()
woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities/chat.py 0000664 0000000 0000000 00000002776 11713545762 0030540 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Christophe Benz
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
import datetime
from .base import IBaseCap, CapBaseObject
__all__ = ['ChatException', 'ICapChat']
class ChatException(Exception):
pass
class ChatMessage(CapBaseObject):
def __init__(self, id_from, id_to, message, date=None):
CapBaseObject.__init__(self, '%s.%s' % (id_from, id_to))
self.add_field('id_from', basestring, id_from)
self.add_field('id_to', basestring, id_to)
self.add_field('message', basestring, message)
self.add_field('date', datetime.datetime, date)
if self.date is None:
self.date = datetime.datetime.utcnow()
class ICapChat(IBaseCap):
def iter_chat_messages(self, _id=None):
raise NotImplementedError()
def send_chat_message(self, _id, message):
raise NotImplementedError()
collection.py 0000664 0000000 0000000 00000006256 11713545762 0031672 0 ustar 00root root 0000000 0000000 woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities # -*- coding: utf-8 -*-
# Copyright(C) 2010-2012 Nicolas Duhamel, Laurent Bachelier
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
from .base import IBaseCap
__all__ = ['ICapCollection', 'Collection', 'CollectionNotFound']
class CollectionNotFound(Exception):
def __init__(self, split_path=None):
if split_path is not None:
msg = 'Collection not found: %s' % '/'.join(split_path)
else:
msg = 'Collection not found'
Exception.__init__(self, msg)
class Children(object):
"""
Dynamic property of a Collection.
Returns a list, either by calling a function or because
it already has the list.
"""
def __get__(self, obj, type=None):
if obj._children is None:
if callable(obj._fct):
obj._children = obj._fct(obj.id)
return obj._children or []
class Collection(object):
"""
Collection of objects.
Should provide a way to be filled, either by providing the children
right away, or a function. The function will be called once with the id
as an argument if there were no children provided, but only on demand.
It can be found in a list of objects, it indicantes a "folder"
you can hop into.
id and title should be unicode.
"""
children = Children()
def __init__(self, _id=None, title=None, children=None, fct=None):
self.id = _id
self.title = title
# It does not make sense to have both at init
assert not (fct is not None and children is not None)
self._children = children
self._fct = fct
def __iter__(self):
return iter(self.children)
def __unicode__(self):
if self.title and self.id:
return u'%s (%s)' % (self.id, self.title)
elif self.id:
return u'%s' % self.id
else:
return u'Unknown collection'
class ICapCollection(IBaseCap):
def _flatten_resources(self, resources, clean_only=False):
"""
Expand all collections in a list
If clean_only is True, do not expand collections, only remove them.
"""
lst = list()
for resource in resources:
if isinstance(resource, (list, Collection)):
if not clean_only:
lst.extend(self._flatten_resources(resource))
else:
lst.append(resource)
return lst
def iter_resources(self, objs, split_path):
"""
split_path is a list, either empty (root path) or with one or many
components.
"""
raise NotImplementedError()
woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities/contact.py0000664 0000000 0000000 00000010706 11713545762 0031244 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Romain Bignon
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
from .base import IBaseCap, CapBaseObject
from weboob.tools.ordereddict import OrderedDict
__all__ = ['ICapContact', 'Contact']
class ProfileNode(object):
HEAD = 0x01
SECTION = 0x02
def __init__(self, name, label, value, sufix=None, flags=0):
self.name = name
self.label = label
self.value = value
self.sufix = sufix
self.flags = flags
def __getitem__(self, key):
return self.value[key]
class ContactPhoto(CapBaseObject):
def __init__(self, name):
CapBaseObject.__init__(self, name)
self.add_field('name', basestring, name)
self.add_field('url', basestring)
self.add_field('data', str)
self.add_field('thumbnail_url', basestring)
self.add_field('thumbnail_data', basestring)
self.add_field('hidden', bool, False)
def __iscomplete__(self):
return (self.data and (not self.thumbnail_url or self.thumbnail_data))
def __str__(self):
return self.url
def __repr__(self):
return u'' % (self.id,
len(self.data) if self.data else 0,
len(self.thumbnail_data) if self.thumbnail_data else 0)
class Contact(CapBaseObject):
STATUS_ONLINE = 0x001
STATUS_AWAY = 0x002
STATUS_OFFLINE = 0x004
STATUS_ALL = 0xfff
def __init__(self, id, name, status):
CapBaseObject.__init__(self, id)
self.add_field('name', basestring, name)
self.add_field('status', int, status)
self.add_field('url', basestring)
self.add_field('status_msg', basestring)
self.add_field('summary', basestring)
self.add_field('photos', dict, OrderedDict())
self.add_field('profile', dict)
def set_photo(self, name, **kwargs):
if not name in self.photos:
self.photos[name] = ContactPhoto(name)
photo = self.photos[name]
for key, value in kwargs.iteritems():
setattr(photo, key, value)
class QueryError(Exception):
pass
class Query(CapBaseObject):
def __init__(self, id, message):
CapBaseObject.__init__(self, id)
self.add_field('message', basestring, message)
class ICapContact(IBaseCap):
def iter_contacts(self, status=Contact.STATUS_ALL, ids=None):
"""
Iter contacts
@param status get only contacts with the specified status
@param ids if set, get the specified contacts
@return iterator over the contacts found
"""
raise NotImplementedError()
def get_contact(self, id):
"""
Get a contact from his id.
The default implementation only calls iter_contacts()
with the proper values, but it might be overloaded
by backends.
@param id the ID requested
@return the Contact object, or None if not found
"""
l = self.iter_contacts(ids=[id])
try:
return l[0]
except IndexError:
return None
def send_query(self, id):
"""
Send a query to a contact
@param id the ID of contact
@return a Query object
@except QueryError
"""
raise NotImplementedError()
def get_notes(self, id):
"""
Get personal notes about a contact
@param id the ID of the contact
@return a unicode object
"""
raise NotImplementedError
def save_notes(self, id, notes):
"""
Set personal notes about a contact
@param id the ID of the contact
@param notes the unicode object to save as notes
"""
raise NotImplementedError
woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities/content.py0000664 0000000 0000000 00000003406 11713545762 0031262 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Romain Bignon
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
from .base import IBaseCap, CapBaseObject
from datetime import datetime
class Content(CapBaseObject):
def __init__(self, id):
CapBaseObject.__init__(self, id)
self.add_field('title', basestring)
self.add_field('author', basestring)
self.add_field('content', basestring)
self.add_field('revision', basestring)
class Revision(CapBaseObject):
def __init__(self, _id):
CapBaseObject.__init__(self, _id)
self.add_field('author', basestring)
self.add_field('comment', basestring)
self.add_field('revision', basestring)
self.add_field('timestamp', datetime)
self.add_field('minor', bool)
class ICapContent(IBaseCap):
def get_content(self, id, revision=None):
raise NotImplementedError()
def iter_revisions(self, id, max_results=10):
raise NotImplementedError()
def push_content(self, content, message=None, minor=False):
raise NotImplementedError()
def get_content_preview(self, content):
raise NotImplementedError()
woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities/dating.py 0000664 0000000 0000000 00000004461 11713545762 0031060 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Romain Bignon
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
import datetime
from .base import IBaseCap, CapBaseObject
from .contact import Contact
__all__ = ['ICapDating']
class OptimizationNotFound(Exception):
pass
class Optimization(object):
# Configuration of optim can be made by Value*s in this dict.
CONFIG = {}
def start(self):
raise NotImplementedError()
def stop(self):
raise NotImplementedError()
def is_running(self):
raise NotImplementedError()
def get_config(self):
return None
def set_config(self, params):
raise NotImplementedError()
class Event(CapBaseObject):
def __init__(self, id):
CapBaseObject.__init__(self, id)
self.add_field('date', (datetime.datetime))
self.add_field('contact', Contact)
self.add_field('type', basestring)
self.add_field('message', basestring)
class ICapDating(IBaseCap):
def init_optimizations(self):
raise NotImplementedError()
def add_optimization(self, name, optim):
setattr(self, 'OPTIM_%s' % name, optim)
def iter_optimizations(self, *optims):
for attr_name in dir(self):
if not attr_name.startswith('OPTIM_'):
continue
attr = getattr(self, attr_name)
if attr is None:
continue
yield attr_name[6:], attr
def get_optimization(self, optim):
optim = optim.upper()
if not hasattr(self, 'OPTIM_%s' % optim):
raise OptimizationNotFound()
return getattr(self, 'OPTIM_%s' % optim)
def iter_events(self):
raise NotImplementedError()
woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities/gallery.py0000664 0000000 0000000 00000007316 11713545762 0031253 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Romain Bignon, Christophe Benz, NoƩ Rubinstein
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
from datetime import datetime
from weboob.tools.capabilities.thumbnail import Thumbnail
from .base import IBaseCap, CapBaseObject, NotLoaded
__all__ = ['Thumbnail', 'ICapGallery', 'BaseGallery', 'BaseImage']
class BaseGallery(CapBaseObject):
"""
Represents a gallery.
This object has to be inherited to specify how to calculate the URL of the gallery from its ID.
"""
def __init__(self, _id, title=NotLoaded, url=NotLoaded, cardinality=NotLoaded, date=NotLoaded,
rating=NotLoaded, rating_max=NotLoaded, thumbnail=NotLoaded, thumbnail_url=None, nsfw=False):
CapBaseObject.__init__(self, unicode(_id))
self.add_field('title', basestring, title)
self.add_field('url', basestring, url)
self.add_field('description', basestring)
self.add_field('cardinality', int)
self.add_field('date', datetime, date)
self.add_field('rating', (int,long,float), rating)
self.add_field('rating_max', (int,long,float), rating_max)
self.add_field('thumbnail', Thumbnail, thumbnail)
@classmethod
def id2url(cls, _id):
"""Overloaded in child classes provided by backends."""
raise NotImplementedError()
@property
def page_url(self):
return self.id2url(self.id)
def iter_image(self):
raise NotImplementedError()
class BaseImage(CapBaseObject):
def __init__(self, _id, index=None, thumbnail=NotLoaded, url=NotLoaded,
ext=NotLoaded, gallery=None):
CapBaseObject.__init__(self, unicode(_id))
self.add_field('index', int, index) # usually page number
self.add_field('thumbnail', Thumbnail, thumbnail)
self.add_field('url', basestring, url)
self.add_field('ext', basestring, ext)
self.add_field('data', str)
self.add_field('gallery', BaseGallery, gallery)
def __str__(self):
return self.url
def __repr__(self):
return '' % self.url
def __iscomplete__(self):
return self.data is not NotLoaded
class ICapGallery(IBaseCap):
"""
This capability represents the ability for a website backend to provide videos.
"""
(SEARCH_RELEVANCE,
SEARCH_RATING,
SEARCH_VIEWS,
SEARCH_DATE) = range(4)
def iter_search_results(self, pattern=None, sortby=SEARCH_RELEVANCE, max_results=None):
"""
Iter results of a search on a pattern. Note that if pattern is None,
it get the latest videos.
@param pattern [str] pattern to search on
@param sortby [enum] sort by...
@param nsfw [bool] include non-suitable for work videos if True
@param max_results [int] maximum number of results to return
"""
raise NotImplementedError()
def get_gallery(self, _id):
"""
Get gallery from an ID.
@param _id the gallery id. It can be a numeric ID, or a page url, or so.
@return a Gallery object
"""
raise NotImplementedError()
geolocip.py 0000664 0000000 0000000 00000002645 11713545762 0031336 0 ustar 00root root 0000000 0000000 woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Romain Bignon
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
from .base import IBaseCap, CapBaseObject
__all__ = ['IpLocation', 'ICapGeolocIp']
class IpLocation(CapBaseObject):
def __init__(self, ipaddr):
CapBaseObject.__init__(self, ipaddr)
self.ipaddr = ipaddr
self.add_field('city', basestring)
self.add_field('region', basestring)
self.add_field('zipcode', basestring)
self.add_field('country', basestring)
self.add_field('lt', float)
self.add_field('lg', float)
self.add_field('host', basestring)
self.add_field('tld', basestring)
self.add_field('isp', basestring)
class ICapGeolocIp(IBaseCap):
def get_location(self, ipaddr):
raise NotImplementedError()
messages.py 0000664 0000000 0000000 00000012256 11713545762 0031343 0 ustar 00root root 0000000 0000000 woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Romain Bignon
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
import datetime
import time
from .base import IBaseCap, CapBaseObject, NotLoaded
__all__ = ['ICapMessages', 'ICapMessagesPost', 'Message', 'Thread', 'CantSendMessage']
class Message(CapBaseObject):
IS_HTML = 0x001 # The content is HTML formatted
IS_UNREAD = 0x002 # The message is unread
IS_ACCUSED = 0x004 # The receiver has read this message
IS_NOT_ACCUSED = 0x008 # The receiver has not read this message
def __init__(self, thread, id,
title=NotLoaded,
sender=NotLoaded,
receivers=NotLoaded,
date=None,
parent=NotLoaded,
content=NotLoaded,
signature=NotLoaded,
children=NotLoaded,
flags=0):
CapBaseObject.__init__(self, id)
assert thread is not None
self.add_field('thread', Thread, thread)
self.add_field('title', basestring, title)
self.add_field('sender', basestring, sender)
self.add_field('receivers', list, receivers)
self.add_field('date', (datetime.datetime, datetime.date), date)
self.add_field('parent', Message, parent)
self.add_field('content', basestring, content)
self.add_field('signature', basestring, signature)
self.add_field('children', list, children)
self.add_field('flags', int, flags)
if date is None:
date = datetime.datetime.utcnow()
self.date = date
if isinstance(parent, Message):
self.parent = parent
else:
self.parent = NotLoaded
self._parent_id = parent
@property
def date_int(self):
return int(time.strftime('%Y%m%d%H%M%S', self.date.timetuple()))
@property
def full_id(self):
return '%s.%s' % (self.thread.id, self.id)
@property
def full_parent_id(self):
if self.parent:
return self.parent.full_id
elif self._parent_id is None:
return ''
elif self._parent_id is NotLoaded:
return NotLoaded
else:
return '%s.%s' % (self.thread.id, self._parent_id)
def __eq__(self, msg):
if self.thread:
return unicode(self.thread.id) == unicode(msg.thread.id) and \
unicode(self.id) == unicode(msg.id)
else:
return unicode(self.id) == unicode(msg.id)
def __repr__(self):
return '' % (
self.full_id, self.title, self.date, self.sender)
class Thread(CapBaseObject):
IS_THREADS = 0x001
IS_DISCUSSION = 0x002
def __init__(self, id):
CapBaseObject.__init__(self, id)
self.add_field('root', Message)
self.add_field('title', basestring)
self.add_field('date', (datetime.datetime, datetime.date))
self.add_field('nb_messages', int)
self.add_field('nb_unread', int)
self.add_field('flags', int, self.IS_THREADS)
def iter_all_messages(self):
if self.root:
yield self.root
for m in self._iter_all_messages(self.root):
yield m
def _iter_all_messages(self, message):
if message.children:
for child in message.children:
yield child
for m in self._iter_all_messages(child):
yield m
class ICapMessages(IBaseCap):
def iter_threads(self):
"""
Iterates on threads, from newers to olders.
@return [iter] Thread objects
"""
raise NotImplementedError()
def get_thread(self, id):
"""
Get a specific thread.
@return [Thread] the Thread object
"""
raise NotImplementedError()
def iter_unread_messages(self, thread=None):
"""
Iterates on messages which hasn't been marked as read.
@param thread thread name (optional)
@return [iter] Message objects
"""
raise NotImplementedError()
def set_message_read(self, message):
"""
Set a message as read.
@param [message] message read (or ID)
"""
raise NotImplementedError()
class CantSendMessage(Exception):
pass
class ICapMessagesPost(IBaseCap):
def post_message(self, message):
"""
Post a message.
@param message Message object
@return
"""
raise NotImplementedError()
woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities/paste.py 0000664 0000000 0000000 00000006162 11713545762 0030726 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2011 Laurent Bachelier
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
from .base import IBaseCap, CapBaseObject, NotLoaded
__all__ = ['PasteNotFound', 'BasePaste', 'ICapPaste']
class PasteNotFound(Exception):
pass
class BasePaste(CapBaseObject):
"""
Represents a pasted text.
"""
def __init__(self, _id, title=NotLoaded, language=NotLoaded, contents=NotLoaded,
public=NotLoaded):
CapBaseObject.__init__(self, unicode(_id))
self.add_field('title', basestring, title)
self.add_field('language', basestring, language)
self.add_field('contents', basestring, contents)
self.add_field('public', bool, public)
@classmethod
def id2url(cls, _id):
"""Overloaded in child classes provided by backends."""
raise NotImplementedError()
@property
def page_url(self):
return self.id2url(self.id)
class ICapPaste(IBaseCap):
"""
This capability represents the ability for a website backend to store plain text.
"""
def new_paste(self, *args, **kwargs):
"""
Get a new paste object for posting it with the backend.
The parameters should be passed to the object init.
@return a Paste object
"""
raise NotImplementedError()
def can_post(self, contents, title=None, public=None, max_age=None):
"""
Checks if the paste can be pasted by this backend.
Some properties are considered required (public/private, max_age) while others
are just bonuses (language).
contents: Can be used to check encodability, maximum length, etc.
title: Can be used to check length, allowed characters. Should not be required.
public: True must be public, False must be private, None do not care.
max_age: Maximum time to live in seconds.
A score of 0 means the backend is not suitable.
A score of 1 means the backend is suitable.
Higher scores means it is more suitable than others with a lower score.
@return int Score
"""
raise NotImplementedError()
def get_paste(self, url):
"""
Get a Paste from an ID or URL.
@param _id the paste id. It can be an ID or a page URL.
@return a Paste object
"""
raise NotImplementedError()
def post_paste(self, paste, max_age=None):
"""
Post a paste.
@param paste Paste object
@return
"""
raise NotImplementedError()
woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities/radio.py 0000664 0000000 0000000 00000004002 11713545762 0030677 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Romain Bignon
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
from .base import IBaseCap, CapBaseObject
__all__ = ['Emission', 'Stream', 'Radio', 'ICapRadio']
class Emission(CapBaseObject):
def __init__(self, id):
CapBaseObject.__init__(self, id)
self.add_field('artist', unicode)
self.add_field('title', unicode)
def __iscomplete__(self):
# This volatile information may be reloaded everytimes.
return False
def __unicode__(self):
if self.artist:
return u'%s - %s' % (self.artist, self.title)
else:
return self.title
class Stream(CapBaseObject):
def __init__(self, id):
CapBaseObject.__init__(self, id)
self.add_field('title', unicode)
self.add_field('url', unicode)
def __unicode__(self):
return u'%s (%s)' % (self.title, self.url)
def __repr__(self):
return self.__unicode__()
class Radio(CapBaseObject):
def __init__(self, id):
CapBaseObject.__init__(self, id)
self.add_field('title', unicode)
self.add_field('description', unicode)
self.add_field('current', Emission)
self.add_field('streams', list)
class ICapRadio(IBaseCap):
def iter_radios_search(self, pattern):
raise NotImplementedError()
def get_radio(self, id):
raise NotImplementedError()
woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities/torrent.py0000664 0000000 0000000 00000003602 11713545762 0031303 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Romain Bignon, Laurent Bachelier
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
from datetime import datetime
from .base import IBaseCap, CapBaseObject, NotLoaded
__all__ = ['ICapTorrent', 'Torrent']
class Torrent(CapBaseObject):
def __init__(self, id, name, date=NotLoaded, size=NotLoaded, url=NotLoaded,
seeders=NotLoaded, leechers=NotLoaded, files=NotLoaded,
description=NotLoaded, filename=NotLoaded):
CapBaseObject.__init__(self, id)
self.add_field('name', basestring, name)
self.add_field('size', (int,long,float), size)
self.add_field('date', datetime, date)
self.add_field('url', basestring, url)
self.add_field('seeders', int, seeders)
self.add_field('leechers', int, leechers)
self.add_field('files', list, files)
self.add_field('description', basestring, description)
self.add_field('filename', basestring, filename) # suggested name of the .torrent file
class ICapTorrent(IBaseCap):
def iter_torrents(self, pattern):
raise NotImplementedError()
def get_torrent(self, _id):
raise NotImplementedError()
def get_torrent_file(self, _id):
raise NotImplementedError()
woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities/travel.py 0000664 0000000 0000000 00000006467 11713545762 0031117 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Romain Bignon, Julien Hebert
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
from datetime import time, datetime, timedelta
from .base import IBaseCap, CapBaseObject
__all__ = ['Departure', 'ICapTravel', 'Station']
class Station(CapBaseObject):
def __init__(self, id, name):
CapBaseObject.__init__(self, id)
self.add_field('name', basestring, name)
def __repr__(self):
return "" % (self.id, self.name)
class Departure(CapBaseObject):
def __init__(self, id, _type, _time):
CapBaseObject.__init__(self, id)
self.add_field('type', basestring, _type)
self.add_field('time', datetime, _time)
self.add_field('departure_station', basestring)
self.add_field('arrival_station', basestring)
self.add_field('late', time, time())
self.add_field('information', basestring)
self.add_field('plateform', basestring)
def __repr__(self):
return u"" % (
self.id, self.type, self.time.strftime('%H:%M'), self.departure_station, self.arrival_station)
class RoadStep(CapBaseObject):
def __init__(self, id):
CapBaseObject.__init__(self, id)
self.add_field('line', basestring)
self.add_field('start_time', time)
self.add_field('end_time', time)
self.add_field('departure', unicode)
self.add_field('arrival', unicode)
self.add_field('duration', timedelta)
class RoadmapError(Exception):
pass
class RoadmapFilters(CapBaseObject):
def __init__(self):
CapBaseObject.__init__(self, '')
self.add_field('departure_time', datetime)
self.add_field('arrival_time', datetime)
class ICapTravel(IBaseCap):
def iter_station_search(self, pattern):
"""
Iterates on search results of stations.
@param pattern [str] the search pattern
@return [iter] the of Station objects
"""
raise NotImplementedError()
def iter_station_departures(self, station_id, arrival_id):
"""
Iterate on departures.
@param station_id [id] the station id
@param arrival_id [id] optionnal arrival station id
@return [iter] result of Departure objects
"""
raise NotImplementedError()
def iter_roadmap(self, departure, arrival, filters):
"""
Get a roadmap.
@param departure [str] name of departure station
@param arrival [str] name of arrival station
@param filters [RoadmapFilters] filters on search
@return [iter(RoadStep)] steps of roadmap
"""
raise NotImplementedError()
woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities/video.py 0000664 0000000 0000000 00000006407 11713545762 0030722 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Romain Bignon, Christophe Benz
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
from datetime import datetime, timedelta
from .base import IBaseCap, CapBaseObject, NotLoaded
from weboob.tools.capabilities.thumbnail import Thumbnail
__all__ = ['BaseVideo', 'ICapVideo']
class BaseVideo(CapBaseObject):
"""
Represents a video.
This object has to be inherited to specify how to calculate the URL of the video from its ID.
"""
def __init__(self, _id, title=NotLoaded, url=NotLoaded, author=NotLoaded, duration=NotLoaded, date=NotLoaded,
rating=NotLoaded, rating_max=NotLoaded, thumbnail=NotLoaded, thumbnail_url=None, nsfw=False):
CapBaseObject.__init__(self, unicode(_id))
self.add_field('title', basestring, title)
self.add_field('url', basestring, url)
self.add_field('ext', basestring)
self.add_field('author', basestring, author)
self.add_field('description', basestring)
self.add_field('duration', (int,long,timedelta), duration)
self.add_field('date', datetime, date)
self.add_field('rating', (int,long,float), rating)
self.add_field('rating_max', (int,long,float), rating_max)
self.add_field('thumbnail', Thumbnail, thumbnail)
self.add_field('nsfw', bool, nsfw)
# XXX remove this and fix all backends
if thumbnail_url is not None and self.thumbnail is NotLoaded:
self.thumbnail = Thumbnail(thumbnail_url)
@classmethod
def id2url(cls, _id):
"""Overloaded in child classes provided by backends."""
raise NotImplementedError()
@property
def page_url(self):
return self.id2url(self.id)
class ICapVideo(IBaseCap):
"""
This capability represents the ability for a website backend to provide videos.
"""
(SEARCH_RELEVANCE,
SEARCH_RATING,
SEARCH_VIEWS,
SEARCH_DATE) = range(4)
def iter_search_results(self, pattern=None, sortby=SEARCH_RELEVANCE, nsfw=False, max_results=None):
"""
Iter results of a search on a pattern. Note that if pattern is None,
it get the latest videos.
@param pattern [str] pattern to search on
@param sortby [enum] sort by...
@param nsfw [bool] include non-suitable for work videos if True
@param max_results [int] maximum number of results to return
"""
raise NotImplementedError()
def get_video(self, _id):
"""
Get a Video from an ID.
@param _id the video id. It can be a numeric ID, or a page url, or so.
@return a Video object
"""
raise NotImplementedError()
woob-0.a-7e000895908c0941e58c7311b68234a4b827e76c-weboob-capabilities/weboob/capabilities/weather.py0000664 0000000 0000000 00000003777 11713545762 0031262 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Romain Bignon
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
from datetime import datetime
from .base import IBaseCap, CapBaseObject
__all__ = ['City', 'CityNotFound', 'Current', 'Forecast', 'ICapWeather']
class Forecast(CapBaseObject):
def __init__(self, date, low, high, text, unit):
CapBaseObject.__init__(self, date)
self.add_field('date', (basestring,datetime), date)
self.add_field('low', (int,float), low)
self.add_field('high', (int,float), high)
self.add_field('text', basestring, text)
self.add_field('unit', basestring, unit)
class Current(CapBaseObject):
def __init__(self, date, temp, text, unit):
CapBaseObject.__init__(self, date)
self.add_field('date', (basestring,datetime), date)
self.add_field('text', basestring, text)
self.add_field('temp', (int,float), temp)
self.add_field('unit', basestring, unit)
class City(CapBaseObject):
def __init__(self, id, name):
CapBaseObject.__init__(self, id)
self.add_field('name', basestring, name)
class CityNotFound(Exception):
pass
class ICapWeather(IBaseCap):
def iter_city_search(self, pattern):
raise NotImplementedError()
def get_current(self, city_id):
raise NotImplementedError()
def iter_forecast(self, city_id):
raise NotImplementedError()