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'¶
- 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()
- 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:
- 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.