woob.tools.application.console

class ConsoleApplication(option_parser=None)[source]

Bases: Application

Base application class for CLI applications.

CAPS = None
BOLD = '\x1b[1m'
NC = '\x1b[0m'
login_cb(backend_name, value)[source]
unload_backends(*args, **kwargs)[source]
is_module_loadable(info)[source]
load_backends(*args, **kwargs)[source]
check_loaded_backends(default_config=None)[source]
prompt_create_backends(default_config=None)[source]
load_default_backends()[source]

By default loads all backends.

Applications can overload this method to restrict backends loaded.

classmethod run(args=None)[source]

This static method can be called to run the application.

It creates the application object, handles options, setups logging, calls the main() method, and catches common exceptions.

You can’t do anything after this call, as it always finishes with a call to sys.exit().

For example:

>>> from woob.application.myapplication import MyApplication
>>> MyApplication.run()
do(function, *args, **kwargs)[source]
parse_id(_id, unique_backend=False)[source]
register_backend(name, ask_add=True)[source]
install_module(minfo)[source]
edit_backend(name, params=None)[source]
add_backend(module_name, backend_name, params=None, edit=False, ask_register=True)[source]
ask(question, default=None, masked=None, regexp=None, choices=None, tiny=None)[source]

Ask a question to user.

Parameters:
  • question (str) – text displayed

  • default (str) – optional default value (default: None)

  • masked (bool) – if True, do not show typed text (default: None)

  • regexp (str) – text must match this regexp (default: None)

  • choices (list) – choices to do (default: None)

  • tiny (bool) – ask for the (small) value of the choice (default: None)

Returns:

text by user

Return type:

str

print(txt)[source]
acquire_input(content=None, editor_params=None, suffix=None)[source]

Get an input from a text editor.

If the EDITOR environment variable is empty, acquire from stdin.

You can provide editor_params to supply parameters to editor. For example:

{'vim': "-c 'set ft=mail'"}

The suffix argument is for the temporary filename, that’s useful to highlight content.

Parameters:
  • content (str) – default content to write in the file to edit (default: None)

  • editor_params (dict) – parameters to supply to editor (default: None)

  • suffix (str) – file suffix (default: None)

Return type:

str

bcall_error_handler(backend, error, backtrace)[source]

Handler for an exception inside the CallErrors exception.

This method can be overridden to support more exceptions types.

bcall_errors_handler(errors, debugmsg='Use --debug option to print backtraces', ignore=())[source]

Handler for the CallErrors exception.

exception BackendNotGiven(id, backends)[source]

Bases: Exception