def _page(output, pager_command=None):
"""Conditionally pipes the supplied output through a pager.
:param output:
:type output: object
:param pager_command:
:type pager_command: str
"""
output = six.text_type(output)
if pager_command is None:
pager_command = 'less -R'
if not sys.stdout.isatty() or util.is_windows_platform():
print(output)
return
num_lines = output.count('\n')
exceeds_tty_height = pager.getheight() - 1 < num_lines
paginate = util.get_config().get("core.pagination", True)
if exceeds_tty_height and paginate:
pydoc.pipepager(output, cmd=pager_command)
else:
print(output)
评论列表
文章目录