woob.core.ouiboube

class woob.core.ouiboube.WebNip(modules_path=None, storage=None, scheduler=None)

Bases: object

Woob in Non Integrated Programs

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 WebNip, you have to explicitely provide module paths and deal yourself with backend configuration.

Parameters
exception LoadError(backend_name, exception)

Bases: Exception

Raised when a backend is unabled to load.

Parameters
  • backend_name – name of backend we can’t load

  • exception – exception object

VERSION = '2.1'
build_backend(module_name, params=None, storage=None, name=None, nofail=False, logger=None)

Create a backend.

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

Parameters
  • module_name – name of module

  • params (dict) – parameters to give to backend

  • storage (woob.tools.storage.IStorage) – storage to use

  • name (basestring) – name of backend

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

Return type

woob.tools.backend.Module

cancel(ev)

Cancel an event

Parameters

ev – the event identificator

count_backends()

Get number of loaded backends.

deinit()

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

do(function, *args, **kwargs)

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)

get_backend(name, **kwargs)

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.

iter_backends(caps=None, module=None)

Iter on each backends.

Note: each backend is locked when it is returned.

Parameters
Return type

iter[woob.tools.backend.Module]

load_backend(module_name, name, params=None, storage=None)

Load a backend.

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

  • name (basestring) – name of instance

  • params (dict) – parameters to give to backend

  • storage (woob.tools.storage.IStorage) – storage to use

Return type

woob.tools.backend.Module

load_or_install_module(module_name)

Load a backend, but can’t install it

loop()

Run the scheduler loop

repeat(interval, function, *args)

Repeat a call to a function

Parameters
  • interval (int) – interval between two calls

  • function (callable) – function to call

  • args – arguments to give to function

Returns

an event identificator

schedule(interval, function, *args)

Schedule an event.

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

  • function (callabale) – function to call

  • args – arguments to give to function

Returns

an event identificator

unload_backends(names=None)

Unload backends.

Parameters

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

want_stop()

Plan to stop the scheduler.

class woob.core.ouiboube.Weboob(workdir=None, datadir=None, backends_filename=None, scheduler=None, storage=None)

Bases: woob.core.ouiboube.WebNip

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

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

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

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

BACKENDS_FILENAME = 'backends'
build_backend(module_name, params=None, storage=None, name=None, nofail=False)

Create a single backend which is not listed in configuration.

Parameters
  • module_name – name of module

  • params (dict) – parameters to give to backend

  • storage (woob.tools.storage.IStorage) – storage to use

  • name (basestring) – name of backend

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

Return type

woob.tools.backend.Module

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

Load backends listed in config file.

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

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

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

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

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

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

Returns

loaded backends

Return type

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

load_or_install_module(module_name)

Load a backend, and install it if not done before

update(progress=<PrintProgress>)

Update modules from repositories.