woob.tools.backend

class woob.tools.backend.BackendConfig(*values)

Bases: weboob.tools.value.ValuesDict

Configuration of a backend.

This class is firstly instanced as a woob.tools.value.ValuesDict, containing some woob.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(woob, modname, instname, config, nofail=False)

Load configuration from dict to create an instance.

Parameters
  • woob (woob.core.woob.Woob) – woob 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

woob = None
class woob.tools.backend.BackendStorage(name, storage)

Bases: object

This is an abstract layer to store data in storages (woob.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 woob.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 woob.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 woob.tools.backend.Module(*args, **kwargs)

Bases: object

Base class for modules.

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

Parameters

Accept any arguments, necessary for AbstractModule __new__ override.

AbstractModule, in its overridden __new__, removes itself from class hierarchy so its __new__ is called only once. In python 3, default (object) __new__ is then used for next instantiations but it’s a slot/”fixed” version supporting only one argument (type to instanciate).

BROWSER = None

Browser class

CONFIG = {}

Configuration required for backends.

Values must be woob.tools.value.Value objects.

exception ConfigError

Bases: Exception

Raised when the config can’t be loaded.

DESCRIPTION = '<unspecified>'

Description

EMAIL = '<unspecified>'

Email address of the maintainer.

ICON = None

URL to an optional icon.

If you want to create your own icon, create a ‘favicon.png’ icon in the module’s directory, and keep the ICON value to None.

LICENSE = '<unspecified>'
MAINTAINER = '<unspecified>'
NAME = None

Name of the maintainer of this module.

OBJECTS = {}

Supported objects to fill

The key is the class and the value the method to call to fill Method prototype: method(object, fields) When the method is called, fields are only the one which are NOT yet filled.

STORAGE = {}

Storage

VERSION = '<unspecified>'

Version of module (for information only).

property 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.

create_browser(*args, **kwargs)

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

Parameters

klass (woob.browser.browsers.Browser) – optional parameter to give another browser class to instanciate

create_default_browser()

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

deinit()

This abstract method is called when the backend is unloaded.

dump_state()
fillobj(obj, fields=None)

Fill an object with the wanted fields.

Parameters

fields (list) – what fields to fill; if None, all fields are filled

get_proxy()
has_caps(*caps)

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

classmethod iter_caps()

Iter capabilities implemented by this backend.

Return type

iter[woob.capabilities.base.Capability]

property weboob