woob.core.ouiboube

Deprecated since version 3.0: Please use woob.core.woob instead.

class WoobBase(modules_path=None, storage=None, scheduler=None)[source]

Bases: object

Woob class to load modules from a specific path, without deal with woob remote repositories.

It provides methods to build backends or call methods on all loaded backends.

You should use this class when you want to build an application using Woob as a library, without using the standard modules nor the automatic module download and update machanism. When using WoobBase, you have to explicitely provide module paths and deal yourself with backend configuration.

Parameters:
  • modules_path (str) – path to directory containing modules. (default: None)

  • storage (woob.tools.storage.IStorage) – provide a storage where backends can save data (default: None)

  • scheduler (woob.core.scheduler.IScheduler) – what scheduler to use; default is woob.core.scheduler.Scheduler (default: None)

VERSION = '3.6'
deinit()[source]

Call this method when you stop using Woob, to properly unload all correctly.

build_modules_loader()[source]

Build the module loader for the current application.

This can be overridden by children to avoid overriding an already existing modules loader.

Return type:

ModulesLoader

build_backend(module_name, params=None, storage=None, name=None, nofail=False, logger=None)[source]

Create a backend.

It does not load it into the Woob object, so you are responsible for deinitialization and calls.

Parameters:
  • module_name (str) – name of module

  • params (dict) – parameters to give to backend (default: None)

  • storage (woob.tools.storage.IStorage) – storage to use (default: None)

  • name (str) – name of backend (default: None)

  • nofail (bool) – if true, this call can’t fail (default: False)

  • logger (logging.Logger) – logger to use (default: None)

Return type:

woob.tools.backend.Module

exception LoadError(backend_name, message)[source]

Bases: Exception

Raised when a backend is unabled to load.

Parameters:
  • backend_name (str) – name of backend we can’t load

  • exception – exception object

load_backend(module_name, name, params=None, storage=None, nofail=False)[source]

Load a backend.

Parameters:
  • module_name (str:) – name of module to load

  • name (str) – name of instance

  • params (dict) – parameters to give to backend (default: None)

  • storage (woob.tools.storage.IStorage) – storage to use (default: None)

  • nofail (bool) – if true, this call can’t fail (default: False)

Return type:

woob.tools.backend.Module

unload_backends(names=None)[source]

Unload backends.

Parameters:

names (list) – if specified, only unload that backends (default: None)

Return type:

Dict[str, Module]

get_backend(name, **kwargs)[source]

Get a backend from its name.

Parameters:
  • name (str) – name of backend to get

  • default (whatever you want) – if specified, get this value when the backend is not found

Raises:

KeyError if not found.

Return type:

Module

count_backends()[source]

Get number of loaded backends.

Return type:

int

iter_backends(caps=None, module=None)[source]

Iter on each backends.

Note: each backend is locked when it is returned.

Parameters:
Return type:

iter[woob.tools.backend.Module]

do(function, *args, **kwargs)[source]

Do calls on loaded backends with specified arguments, in separated threads.

This function has two modes:

  • If function is a string, it calls the method with this name on each backends with the specified arguments;

  • If function is a callable, it calls it in a separated thread with the locked backend instance at first arguments, and *args and **kwargs.

Parameters:
  • function (str) – backend’s method name, or a callable object

  • backends (list[str]) – list of backends to iterate on

  • caps (list[woob.capabilities.base.Capability]) – iterate on backends which implement this caps

Return type:

A woob.core.bcall.BackendsCall object (iterable)

schedule(interval, function, *args)[source]

Schedule an event.

Parameters:
  • interval (int) – delay before calling the function

  • function (callabale) – function to call

  • args – arguments to give to function

Return type:

int | None

Returns:

an event identificator

repeat(interval, function, *args)[source]

Repeat a call to a function

Parameters:
  • interval (int) – interval between two calls

  • function (callable) – function to call

  • args – arguments to give to function

Return type:

int | None

Returns:

an event identificator

cancel(ev)[source]

Cancel an event

Parameters:

ev (int) – the event identificator

Return type:

bool

want_stop()[source]

Plan to stop the scheduler.

Return type:

None

loop()[source]

Run the scheduler loop

load_or_install_module(module_name)[source]

Load a backend, but can’t install it

Return type:

Module

class Woob(workdir=None, datadir=None, backends_filename=None, scheduler=None, storage=None)[source]

Bases: WoobBase

The main class of Woob, used to manage backends, modules repositories and call methods on all loaded backends.

Parameters:
  • workdir (str) – optional parameter to set path of the working directory (default: None)

  • datadir (str) – optional parameter to set path of the data directory (default: None)

  • backends_filename (str) – name of the backends file, where configuration of (default: None) backends is stored

  • storage (woob.tools.storage.IStorage) – provide a storage where backends can save data (default: None)

BACKENDS_FILENAME = 'backends'
build_modules_loader()[source]

Build the module loader for the current application.

Return type:

ModulesLoader

update(progress=PrintProgress())[source]

Update modules from repositories.

Parameters:

progress (IProgress) – object notified when there is a progress (default: PrintProgress())

build_backend(module_name, params=None, storage=None, name=None, nofail=False, logger=None)[source]

Create a single backend which is not listed in configuration.

Parameters:
  • module_name (str) – name of module

  • params (dict) – parameters to give to backend (default: None)

  • storage (woob.tools.storage.IStorage) – storage to use (default: None)

  • name (str) – name of backend (default: None)

  • nofail (bool) – if true, this call can’t fail (default: False)

Return type:

woob.tools.backend.Module

load_backends(caps=None, names=None, modules=None, exclude=None, storage=None, errors=None)[source]

Load backends listed in config file.

Parameters:
  • caps (tuple[woob.capabilities.base.Capability]) – load backends which implement all of specified caps (default: None)

  • names (tuple[str]) – load backends in list (default: None)

  • modules (tuple[str]) – load backends which module is in list (default: None)

  • exclude (tuple[str]) – do not load backends in list (default: None)

  • storage (woob.tools.storage.IStorage) – use this storage if specified (default: None)

  • errors (list[LoadError]) – if specified, store every errors in this list (default: None)

Returns:

loaded backends

Return type:

dict[str, woob.tools.backend.Module]

load_or_install_module(module_name)[source]

Load a backend, and install it if not done before

Return type:

Module

exception VersionsMismatchError[source]

Bases: ConfigError

Weboob

alias of Woob

WebNip

alias of WoobBase