本文整理匯總了Python中pydoc.__file__方法的典型用法代碼示例。如果您正苦於以下問題:Python pydoc.__file__方法的具體用法?Python pydoc.__file__怎麽用?Python pydoc.__file__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pydoc
的用法示例。
在下文中一共展示了pydoc.__file__方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run_pydoc
# 需要導入模塊: import pydoc [as 別名]
# 或者: from pydoc import __file__ [as 別名]
def run_pydoc(module_name, *args, **env):
"""
Runs pydoc on the specified module. Returns the stripped
output of pydoc.
"""
args = args + (module_name,)
# do not write bytecode files to avoid caching errors
rc, out, err = assert_python_ok('-B', pydoc.__file__, *args, **env)
return out.strip()
示例2: get_pydoc_link
# 需要導入模塊: import pydoc [as 別名]
# 或者: from pydoc import __file__ [as 別名]
def get_pydoc_link(module):
"Returns a documentation web link of a module"
dirname = os.path.dirname
basedir = dirname(dirname(os.path.realpath(__file__)))
doc = pydoc.TextDoc()
loc = doc.getdocloc(module, basedir=basedir)
return loc
示例3: _restricted_walk_packages
# 需要導入模塊: import pydoc [as 別名]
# 或者: from pydoc import __file__ [as 別名]
def _restricted_walk_packages(self, walk_packages, path=None):
"""
A version of pkgutil.walk_packages() that will restrict itself to
a given path.
"""
default_path = path or [os.path.dirname(__file__)]
def wrapper(path=None, prefix='', onerror=None):
return walk_packages(path or default_path, prefix, onerror)
return wrapper
示例4: test_importfile
# 需要導入模塊: import pydoc [as 別名]
# 或者: from pydoc import __file__ [as 別名]
def test_importfile(self):
loaded_pydoc = pydoc.importfile(pydoc.__file__)
self.assertIsNot(loaded_pydoc, pydoc)
self.assertEqual(loaded_pydoc.__name__, 'pydoc')
self.assertEqual(loaded_pydoc.__file__, pydoc.__file__)
self.assertEqual(loaded_pydoc.__spec__, pydoc.__spec__)
示例5: test_url_requests
# 需要導入模塊: import pydoc [as 別名]
# 或者: from pydoc import __file__ [as 別名]
def test_url_requests(self):
# Test for the correct title in the html pages returned.
# This tests the different parts of the URL handler without
# getting too picky about the exact html.
requests = [
("", "Pydoc: Index of Modules"),
("get?key=", "Pydoc: Index of Modules"),
("index", "Pydoc: Index of Modules"),
("topics", "Pydoc: Topics"),
("keywords", "Pydoc: Keywords"),
("pydoc", "Pydoc: module pydoc"),
("get?key=pydoc", "Pydoc: module pydoc"),
("search?key=pydoc", "Pydoc: Search Results"),
("topic?key=def", "Pydoc: KEYWORD def"),
("topic?key=STRINGS", "Pydoc: TOPIC STRINGS"),
("foobar", "Pydoc: Error - foobar"),
("getfile?key=foobar", "Pydoc: Error - getfile?key=foobar"),
]
with self.restrict_walk_packages():
for url, title in requests:
self.call_url_handler(url, title)
path = string.__file__
title = "Pydoc: getfile " + path
url = "getfile?key=" + path
self.call_url_handler(url, title)
示例6: get_pydoc_link
# 需要導入模塊: import pydoc [as 別名]
# 或者: from pydoc import __file__ [as 別名]
def get_pydoc_link(module):
"Returns a documentation web link of a module"
dirname = os.path.dirname
basedir = dirname(dirname(__file__))
doc = pydoc.TextDoc()
loc = doc.getdocloc(module, basedir=basedir)
return loc
示例7: get_pydoc_link
# 需要導入模塊: import pydoc [as 別名]
# 或者: from pydoc import __file__ [as 別名]
def get_pydoc_link(module):
"Returns a documentation web link of a module"
abspath = os.path.abspath
dirname = os.path.dirname
basedir = dirname(dirname(abspath(__file__)))
doc = pydoc.TextDoc()
loc = doc.getdocloc(module, basedir=basedir)
return loc