This module provides an abstract base class that is used for displaying messages and prompting for user input.
See also
CmdLineInterface for an implementation of this class
AUTHORS:
Bases: object
An abstract base class for displaying messages and prompting the user for input.
TESTS:
sage: from sage.dev.user_interface import UserInterface
sage: from sage.dev.test.config import DoctestConfig
sage: UserInterface(DoctestConfig())
<sage.dev.user_interface.UserInterface object at 0x...>
Ask a yes/no question and return the response as a boolean.
INPUT:
TESTS:
sage: from sage.dev.user_interface import UserInterface
sage: from sage.dev.test.config import DoctestConfig
sage: UI = UserInterface(DoctestConfig())
sage: UI.confirm("Should I delete your home directory?")
Traceback (most recent call last):
...
NotImplementedError
Display message.
INPUT:
TESTS:
Debug messages are not displayed in doctests:
sage: from sage.dev.user_interface import UserInterface
sage: from sage.dev.test.config import DoctestConfig
sage: UI = UserInterface(DoctestConfig())
sage: UI.debug("I ate filet mignon for dinner.")
Drop user into an editor with filename open.
OUTPUT:
Raises a sage.dev.user_interface_error.OperationCancelledError if the editor exits with non-zero exit code.
TESTS:
sage: from sage.dev.user_interface import UserInterface
sage: from sage.dev.test.config import DoctestConfig
sage: UI = UserInterface(DoctestConfig())
sage: UI.edit("filename")
Traceback (most recent call last):
...
NotImplementedError
Display message.
INPUT:
TESTS:
sage: from sage.dev.user_interface import UserInterface sage: from sage.dev.test.config import DoctestConfig sage: UI = UserInterface(DoctestConfig()) sage: UI.error(“I ate filet mignon for dinner.”) Traceback (most recent call last): ... NotImplementedError
Read input after displaying prompt.
TESTS:
sage: from sage.dev.user_interface import UserInterface
sage: from sage.dev.test.config import DoctestConfig
sage: UI = UserInterface(DoctestConfig())
sage: UI.get_input("What do you want for dinner?")
Traceback (most recent call last):
...
NotImplementedError
Ask for a password after displaying prompt.
TESTS:
sage: from sage.dev.user_interface import UserInterface
sage: from sage.dev.test.config import DoctestConfig
sage: UI = UserInterface(DoctestConfig())
sage: UI.get_password("What is the passphrase for your safe?")
Traceback (most recent call last):
...
NotImplementedError
Display message.
These are informational messages to be shown to the user, typically indicating how to proceed.
INPUT:
TESTS:
Info messages are not displayed in doctests:
sage: from sage.dev.user_interface import UserInterface
sage: from sage.dev.test.config import DoctestConfig
sage: UI = UserInterface(DoctestConfig())
sage: UI.info("I ate filet mignon for dinner.")
Traceback (most recent call last):
...
NotImplementedError
Ask the user to select from list of options and return selected option.
INPUT:
TESTS:
sage: from sage.dev.user_interface import UserInterface
sage: from sage.dev.test.config import DoctestConfig
sage: UI = UserInterface(DoctestConfig())
sage: UI.select("Should I delete your home directory?", ("yes","no","maybe"), default=1)
Traceback (most recent call last):
...
NotImplementedError
Display message.
INPUT:
TESTS:
sage: from sage.dev.user_interface import UserInterface, DEBUG
sage: from sage.dev.test.config import DoctestConfig
sage: UI = UserInterface(DoctestConfig())
sage: UI.show("I ate filet mignon for dinner.")
Traceback (most recent call last):
...
NotImplementedError
sage: UI.show("I ate filet mignon for dinner.", log_level=DEBUG)
Display message.
INPUT:
TESTS:
sage: from sage.dev.user_interface import UserInterface sage: from sage.dev.test.config import DoctestConfig sage: UI = UserInterface(DoctestConfig()) sage: UI.warning(“I ate filet mignon for dinner.”) Traceback (most recent call last): ... NotImplementedError