![]() |
Belle II Software development
|
Public Member Functions | |
__init__ (self, prompt=None, quit_if_one_screen=False) | |
__enter__ (self) | |
__exit__ (self, exc_type, exc_val, exc_tb) | |
Protected Attributes | |
str | _pager = os.environ.get("PAGER", "less") |
pager program to use | |
str | _prompt = prompt |
prompt string | |
_quit_if_one_screen = quit_if_one_screen | |
flag indicating whether the pager should automatically exit if the content fits on one screen | |
_pager_process = None | |
Pager subprocess. | |
_original_stdout_fd = None | |
Original file descriptor for stdout before entering the context. | |
_original_stderr_fd = None | |
Original file descriptor for stderr before entering the context. | |
_original_stdout = None | |
Original sys.__stdout__ before entering the context. | |
_original_stderr = None | |
Original sys.__stderr__ before entering the context. | |
_original_stdout_isatty = None | |
Original sys.stdout.isatty. | |
_original_stderr_isatty = None | |
Original sys.stderr.isatty. | |
Context manager providing page-wise output using ``less``, similar to how git handles long output of for example ``git diff``. Paging will only be active if the output is to a terminal and not piped into a file or to a different program. Warning: To be able to see `basf2` log messages like `B2INFO() <basf2.B2INFO>` on the paged output you have to set `basf2.logging.enable_python_logging = True <basf2.LogPythonInterface.enable_python_logging>` .. versionchanged:: release-03-00-00 the pager no longer waits until all output is complete but can incrementally show output. It can also show output generated in C++ You can set the environment variable ``$PAGER`` to an empty string or to ``cat`` to disable paging or to a different program (for example ``more``) which should retrieve the output and display it. >>> with Pager(): >>> for i in range(30): >>> print("This is an example on how to use the pager.") Parameters: prompt (str): a string argument allows overriding the description provided by ``less``. Special characters may need escaping. Will only be shown if paging is used and the pager is actually ``less``. quit_if_one_screen (bool): indicating whether the Pager should quit automatically if the content fits on one screen. This implies that the content stays visible on pager exit. True is similar to the behavior of :program:`git diff`, False is similar to :program:`git --help`
Definition at line 159 of file terminal_utils.py.
__init__ | ( | self, | |
prompt = None, | |||
quit_if_one_screen = False ) |
constructor just remembering the arguments
Definition at line 195 of file terminal_utils.py.
__enter__ | ( | self | ) |
entering context
Definition at line 222 of file terminal_utils.py.
__exit__ | ( | self, | |
exc_type, | |||
exc_val, | |||
exc_tb ) |
exiting context
Definition at line 280 of file terminal_utils.py.
|
protected |
Original sys.__stderr__ before entering the context.
Definition at line 216 of file terminal_utils.py.
|
protected |
Original file descriptor for stderr before entering the context.
Definition at line 212 of file terminal_utils.py.
|
protected |
Original sys.stderr.isatty.
Definition at line 220 of file terminal_utils.py.
|
protected |
Original sys.__stdout__ before entering the context.
Definition at line 214 of file terminal_utils.py.
|
protected |
Original file descriptor for stdout before entering the context.
Definition at line 210 of file terminal_utils.py.
|
protected |
Original sys.stdout.isatty.
Definition at line 218 of file terminal_utils.py.
|
protected |
pager program to use
Definition at line 198 of file terminal_utils.py.
|
protected |
Pager subprocess.
Definition at line 208 of file terminal_utils.py.
|
protected |
prompt string
Definition at line 203 of file terminal_utils.py.
|
protected |
flag indicating whether the pager should automatically exit if the content fits on one screen
Definition at line 206 of file terminal_utils.py.