本文整理汇总了Python中pydoc.pipepager方法的典型用法代码示例。如果您正苦于以下问题:Python pydoc.pipepager方法的具体用法?Python pydoc.pipepager怎么用?Python pydoc.pipepager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pydoc
的用法示例。
在下文中一共展示了pydoc.pipepager方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: page_string
# 需要导入模块: import pydoc [as 别名]
# 或者: from pydoc import pipepager [as 别名]
def page_string(str_to_page, pager_cmd):
"""
Page str_to_page via the pager.
"""
# By default, we expect the command to be `less -R`. If that is the
# pager_cmd, but they don't have less on their machine, odds are they're
# just using the default value. In this case the pager will fail, so we'll
# just go via pydoc.pager, which tries to do smarter checking that we don't
# want to bother trying to replicate.
use_fallback_page_function = False
if pager_cmd is None:
use_fallback_page_function = True
elif pager_cmd == FLAG_FALLBACK:
use_fallback_page_function = True
try:
if use_fallback_page_function:
pydoc.pager(str_to_page)
else:
# Otherwise, obey the user.
pydoc.pipepager(str_to_page, cmd=pager_cmd)
except KeyboardInterrupt:
pass
示例2: test_pipepager
# 需要导入模块: import pydoc [as 别名]
# 或者: from pydoc import pipepager [as 别名]
def test_pipepager(self):
# pipepager does not choke on unicode
doc = pydoc.render_doc(self.Q)
saved, os.popen = os.popen, open
try:
with test.test_support.temp_cwd():
pydoc.pipepager(doc, 'pipe')
self.assertEqual(open('pipe').read(), pydoc._encode(doc))
finally:
os.popen = saved
示例3: _pageDoc
# 需要导入模块: import pydoc [as 别名]
# 或者: from pydoc import pipepager [as 别名]
def _pageDoc(title, docString):
docString = _formatDocString(docString)
# pydoc is fooled by conary's wrapping of stdout. override it if needed.
if sys.stdout.isatty():
if _useLess():
# -R parses CSR escape codes properly
pydoc.pager = lambda x: pydoc.pipepager(x, 'less -R')
else:
# PAGER is set if _useLess returns False
pydoc.pager = lambda x: pydoc.pipepager(x, os.environ['PAGER'])
pydoc.pager("Conary API Documentation: %s\n" %
_formatString('B{' + title + '}') + docString)