weboob.tools.backend

class weboob.tools.backend.BackendStorage(name, storage)

Bases: object

This is an abstract layer to store data in storages (weboob.tools.storage) easily.

It is instancied automatically in constructor of Module, in the Module.storage attribute.

Parameters:
delete(*args)

Delete a value from the storage.

Parameters:args – path to delete.
get(*args, **kwargs)

Get a value or a dict of values in storage.

Example:

>>> from weboob.tools.storage import StandardStorage
>>> backend = BackendStorage('blah', StandardStorage('/tmp/cfg'))
>>> backend.storage.get('config', 'nb_of_threads')
10
>>> backend.storage.get('config', 'unexistant', 'path', default='lol')
'lol'
>>> backend.storage.get('config')
{'nb_of_threads': 10, 'other_things': 'blah'}
Parameters:
  • args – path to get
  • default – if specified, default value when path is not found
load(default)

Load storage.

It is made automatically when your backend is created, and use the STORAGE class attribute as default.

Parameters:default (dict) – this is the default tree if storage is empty
save()

Save storage.

set(*args)

Set value in the storage.

Example:

>>> from weboob.tools.storage import StandardStorage
>>> backend = BackendStorage('blah', StandardStorage('/tmp/cfg'))
>>> backend.storage.set('config', 'nb_of_threads', 10)
>>>
Parameters:args – the path where to store value
class weboob.tools.backend.BackendConfig(*values)

Bases: weboob.tools.value.ValuesDict

Configuration of a backend.

This class is firstly instanced as a weboob.tools.value.ValuesDict, containing some weboob.tools.value.Value (and derivated) objects.

Then, using the load() method will load configuration from file and create a copy of the BackendConfig object with the loaded values.

dump()

Dump config in a dictionary.

Return type:dict
instname = None
load(weboob, modname, instname, config, nofail=False)

Load configuration from dict to create an instance.

Parameters:
  • weboob (weboob.core.ouiboube.Weboob) – weboob object
  • modname (str) – name of the module
  • instname (str) – name of this backend
  • params (dict) – parameters to load
  • nofail (bool) – if true, this call can’t fail
Return type:

BackendConfig

modname = None
save(edit=True, params=None)

Save backend config.

Parameters:
  • edit (bool) – if true, it changes config of an existing backend
  • params (dict) – if specified, params to merge with the ones of the current object
weboob = None
class weboob.tools.backend.Module(weboob, name, config=None, storage=None, logger=None, nofail=False)

Bases: object

Base class for modules.

You may derivate it, and also all capabilities you want to implement.

Parameters:
BROWSER = None
CONFIG = BackendConfig()
exception ConfigError

Bases: exceptions.Exception

Raised when the config can’t be loaded.

Module.DESCRIPTION = '<unspecified>'
Module.EMAIL = '<unspecified>'
Module.ICON = None
Module.LICENSE = '<unspecified>'
Module.MAINTAINER = u'<unspecified>'
Module.NAME = None
Module.OBJECTS = {}
Module.STORAGE = {}
Module.VERSION = '<unspecified>'
Module.browser

Attribute ‘browser’. The browser is created at the first call of this attribute, to avoid useless pages access.

Note that the create_default_browser() method is called to create it.

Module.create_browser(*args, **kwargs)

Build a browser from the BROWSER class attribute and the given arguments.

Parameters:klass (weboob.browser.browsers.Browser) – optional parameter to give another browser class to instanciate
Module.create_default_browser()

Method to overload to build the default browser in attribute ‘browser’.

Module.deinit()

This abstract method is called when the backend is unloaded.

Module.fillobj(obj, fields=None)

Fill an object with the wanted fields.

Parameters:fields (list) – what fields to fill; if None, all fields are filled
Module.get_proxy()
Module.has_caps(*caps)

Check if this backend implements at least one of these capabilities.

classmethod Module.iter_caps(klass)

Iter capabilities implemented by this backend.

Return type:iter[weboob.capabilities.base.Capability]