woob.core.ouiboube
¶
Deprecated since version 3.0: Please use woob.core.woob
instead.
- class WoobBase(modules_path: Optional[str] = None, storage: Optional[IStorage] = None, scheduler: Optional[IScheduler] = 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.storage (
woob.tools.storage.IStorage
) – provide a storage where backends can save datascheduler (
woob.core.scheduler.IScheduler
) – what scheduler to use; default iswoob.core.scheduler.Scheduler
- VERSION = '3.4'¶
- build_modules_loader() ModulesLoader [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
- build_backend(module_name: str, params: Optional[dict] = None, storage: Optional[IStorage] = None, name: Optional[str] = None, nofail: bool = False, logger: Logger = None) Module [source]¶
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 backendstorage (
woob.tools.storage.IStorage
) – storage to usename (
str
) – name of backendnofail (
bool
) – if true, this call can’t faillogger (
logging.Logger
) – logger to use
- Return type
- exception LoadError(backend_name: str, exception: Exception)[source]¶
Bases:
Exception
Raised when a backend is unabled to load.
- Parameters
backend_name – name of backend we can’t load
exception – exception object
- load_backend(module_name: str, name: str, params: Optional[dict] = None, storage: IStorage = None, nofail: bool = False)[source]¶
Load a backend.
- Parameters
module_name (
str
:) – name of module to loadname (
str
) – name of instanceparams (
dict
) – parameters to give to backendstorage (
woob.tools.storage.IStorage
) – storage to usenofail (
bool
) – if true, this call can’t fail
- Return type
- unload_backends(names: Optional[List[str]] = None) Dict[str, Module] [source]¶
Unload backends.
- Parameters
names (
list
) – if specified, only unload that backends
- get_backend(name: str, **kwargs) Module [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.
- iter_backends(caps: Optional[List[Capability]] = None, module: Optional[str] = None)[source]¶
Iter on each backends.
Note: each backend is locked when it is returned.
- Parameters
caps (tuple[
woob.capabilities.base.Capability
]) – optional list of capabilities to select backendsmodule (
str
) – optional name of module
- Return type
- do(function: Union[Callable, str], *args, **kwargs) BackendsCall [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 objectbackends (list[
str
]) – list of backends to iterate oncaps (list[
woob.capabilities.base.Capability
]) – iterate on backends which implement this caps
- Return type
A
woob.core.bcall.BackendsCall
object (iterable)
- schedule(interval: int, function: Callable, *args) Optional[int] [source]¶
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
- class Woob(workdir: Optional[str] = None, datadir: Optional[str] = None, backends_filename: Optional[str] = None, scheduler: Optional[IScheduler] = None, storage: Optional[IStorage] = 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
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_modules_loader() RepositoryModulesLoader [source]¶
Build the module loader for the current application.
- Return type
- update(progress: ~woob.core.repositories.IProgress = <PrintProgress>)[source]¶
Update modules from repositories.
- Parameters
progress (IProgress) – object notified when there is a progress
- build_backend(module_name: str, params: Optional[Dict[str, str]] = None, storage: Optional[IStorage] = None, name: Optional[str] = None, nofail: Optional[bool] = False) Module [source]¶
Create a single backend which is not listed in configuration.
- Parameters
module_name (str) – name of module
params (
dict
) – parameters to give to backendstorage (
woob.tools.storage.IStorage
) – storage to usename (
str
) – name of backendnofail (
bool
) – if true, this call can’t fail
- Return type
- load_backends(caps: Optional[List[Union[Capability, str]]] = None, names: Optional[List[str]] = None, modules: Optional[List[str]] = None, exclude: Optional[List[str]] = None, storage: Optional[IStorage] = None, errors: Optional[List[LoadError]] = None) Dict[str, Module] [source]¶
Load backends listed in config file.
- Parameters
caps (tuple[
woob.capabilities.base.Capability
]) – load backends which implement all of specified capsnames (tuple[
str
]) – load backends in listmodules (tuple[
str
]) – load backends which module is in listexclude (tuple[
str
]) – do not load backends in liststorage (
woob.tools.storage.IStorage
) – use this storage if specifiederrors (list[
LoadError
]) – if specified, store every errors in this list
- Returns
loaded backends
- Return type
dict[
str
,woob.tools.backend.Module
]
- exception VersionsMismatchError[source]¶
Bases:
ConfigError