Part of bzrlib.ui View In Hierarchy
This tells the library how to display things to the user. Through this layer different applications can choose the style of UI.
UI Factories are also context managers, for some syntactic sugar some users need.
|Instance Variables||suppressed_warnings||Identifiers for user warnings that should no be emitted.|
|Method||__enter__||Context manager entry support.|
|Method||__exit__||Context manager exit support.|
|Method||be_quiet||Tell the UI to be more quiet, or not.|
|Method||confirm_action||Seek user confirmation for an action.|
|Method||get_password||Prompt the user for a password.|
|Method||make_output_stream||Get a stream for sending out bulk text data.|
|Method||nested_progress_bar||Return a nested progress bar.|
|Method||clear_term||Prepare the terminal for output.|
|Method||choose||Prompt the user for a list of alternatives.|
|Method||get_boolean||Get a boolean question answered from the user.|
|Method||get_integer||Get an integer from the user.|
|Method||make_progress_view||Construct a new ProgressView object for this UI.|
|Method||recommend_upgrade||Recommend the user upgrade a control directory.|
|Method||report_transport_activity||Called by transports as they do IO.|
|Method||log_transport_activity||Write out whatever transport activity has been measured.|
|Method||show_user_warning||Show a warning to the user.|
|Method||show_error||Show an error message (not an exception) to the user.|
|Method||show_message||Show a message to the user.|
|Method||show_warning||Show a warning to the user.|
|Method||_progress_finished||Called by the ProgressTask when it finishes|
|Method||_progress_all_finished||Called when the top-level progress task finished|
|Method||_progress_updated||Called by the ProgressTask when it changes.|
Override in a concrete factory class if initialisation before use is needed.
Override in a concrete factory class if more cleanup than a simple self.clear_term() is needed when the UIFactory is finished with.
Typically this suppresses progress bars; the application may also look at ui_factory.is_quiet().
If the UI is noninteractive, or the user does not want to be asked about this action, True is returned, indicating bzr should just proceed.
The confirmation id allows the user to configure certain actions to always be confirmed or always denied, and for UIs to specialize the display of particular confirmations.
|Parameters||prompt||Suggested text to display to the user.|
|prompt_kwargs||A dictionary of arguments that can be string-interpolated into the prompt.|
|confirmation_id||Unique string identifier for the confirmation.|
|Parameters||prompt||The prompt to present the user (must be unicode)|
|kwargs||Arguments which will be expanded into the prompt. This lets front ends display different things if they so choose.|
|Returns||The password string, return None if the user canceled the request. Note that we do not touch the encoding, users may have whatever they see fit and the password should be transported as is.|
This is used for commands that produce bulk text, such as log or diff output, as opposed to user interaction. This should work even for non-interactive user interfaces. Typically this goes to a decorated version of stdout, but in a GUI it might be appropriate to send it to a window displaying the text.
|Parameters||encoding||Unicode encoding for output; if not specified uses the configured 'output_encoding' if any; otherwise the terminal encoding. (See get_terminal_encoding.)|
|encoding_type||How to handle encoding errors: replace/strict/escape/exact. Default is replace.|
When the bar has been finished with, it should be released by calling bar.finished().
Should be specialized to draw the progress.
This will, for example, clear text progress bars, and leave the cursor at the leftmost position.
Prompt the user for a list of alternatives. :param msg: message to be shown as part of the prompt. :param choices: list of choices, with the individual choices separated by ' ', e.g.: choose("Save changes?", "&Yes &No &Cancel"). The letter after the '&' is the shortcut key for that choice. Thus you can type 'c' to select "Cancel". Shorcuts are case insensitive. The shortcut does not need to be the first letter. If a shorcut key is not provided, the first letter for the choice will be used. :param default: default choice (index), returned for example when enter is pressed for the console version. :return: the index fo the user choice (so '0', '1' or '2' for respectively yes/no/cancel in the previous example).
|Parameters||prompt||a message to prompt the user with. Should be a single line without terminating n.|
|Returns||True or False for y/yes or n/no.|
Application code should normally not call this but instead nested_progress_bar().
|Parameters||current_format_name||Description of the current format|
|basedir||Location of the control dir|
This may update a progress bar, spinner, or similar display. By default it does nothing.
Implementations are allowed to do nothing, but it is useful if they can write a line to the log file.
|Parameters||display||If False, only log to disk, if True also try to display a message to the user.|
This is specifically for things that are under the user's control (eg outdated formats), not for internal program warnings like deprecated APIs.
This can be overridden by UIFactory subclasses to show it in some appropriate way; the default UIFactory is noninteractive and does nothing. format_user_warning maps it to a string, though other presentations can be used for particular UIs.
|Parameters||warning_id||An identifier like 'cross_format_fetch' used to check if the message is suppressed and to look up the string.|
|message_args||Arguments to be interpolated into the message.|