本文整理匯總了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)