本文整理汇总了Python中pydoc.doc函数的典型用法代码示例。如果您正苦于以下问题:Python doc函数的具体用法?Python doc怎么用?Python doc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了doc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test02_dir
def test02_dir(self):
"""For the same reasons as test01_kdcraw, this used to crash."""
import cppyy, pydoc
assert not '__abstractmethods__' in dir(cppyy.gbl.gInterpreter)
assert '__class__' in dir(cppyy.gbl.gInterpreter)
self.__class__.helpout = []
pydoc.doc(cppyy.gbl.gInterpreter)
helptext = ''.join(self.__class__.helpout)
assert 'TInterpreter' in helptext
assert 'CPPInstance' in helptext
assert 'AddIncludePath' in helptext
cppyy.cppdef("namespace cppyy_regression_test { void iii() {}; }")
assert not 'iii' in cppyy.gbl.cppyy_regression_test.__dict__
assert not '__abstractmethods__' in dir(cppyy.gbl.cppyy_regression_test)
assert '__class__' in dir(cppyy.gbl.cppyy_regression_test)
assert 'iii' in dir(cppyy.gbl.cppyy_regression_test)
assert not 'iii' in cppyy.gbl.cppyy_regression_test.__dict__
assert cppyy.gbl.cppyy_regression_test.iii
assert 'iii' in cppyy.gbl.cppyy_regression_test.__dict__
self.__class__.helpout = []
pydoc.doc(cppyy.gbl.cppyy_regression_test)
helptext = ''.join(self.__class__.helpout)
assert 'CPPInstance' in helptext
示例2: test01_kdcraw
def test01_kdcraw(self):
"""Doc strings for KDcrawIface (used to crash)."""
import cppyy, pydoc
# TODO: run a find for these paths
qtpath = "/usr/include/qt5"
kdcraw_h = "/usr/include/KF5/KDCRAW/kdcraw/kdcraw.h"
if not os.path.isdir(qtpath) or not os.path.exists(kdcraw_h):
import warnings
warnings.warn("no KDE/Qt found, skipping test01_kdcraw")
return
# need to resolve qt_version_tag for the incremental compiler; since
# it's not otherwise used, just make something up
cppyy.cppdef("int qt_version_tag = 42;")
cppyy.add_include_path(qtpath)
cppyy.include(kdcraw_h)
from cppyy.gbl import KDcrawIface
self.__class__.helpout = []
pydoc.doc(KDcrawIface.KDcraw)
helptext = ''.join(self.__class__.helpout)
assert 'KDcraw' in helptext
assert 'CPPInstance' in helptext
示例3: main
def main():
print(plain(doc(device_mount)))
for device_name in inventory_unmounted():
demonstrate(device_name)
return os.EX_OK
print('All configured devices are mounted. Demonstration cancelled.')
return os.EX_TEMPFAIL
示例4: draw
def draw():
""" Select a device/interface and demonstrate."""
print(plain(doc(interface_configuration)))
foundInterface = False
G = nx.Graph()
for device_name in sorted(inventory_connected()):
G.add_node(device_name)
print("%s:" % device_name)
mgmt_name = management_interface(device_name)
for interface_name in sorted(interface_names(device_name)):
# Choose interface on 'data plane' not 'control plane'.
if interface_name == mgmt_name:
continue
else:
match(device_name, interface_name)
foundInterface = True
demonstrate(device_name, interface_name)
to_interface = interface_configuration(device_name, interface_name)[1].split(" ")[1]
print("interface:%s" % to_interface)
G.add_edge(device_name, to_interface)
if not foundInterface:
print("There are no suitable network interfaces for this device.")
print(G.nodes())
print(G.edges())
# nx.draw(G)
nx.draw_networkx(G, with_labels=True)
plt.show()
示例5: main
def main():
"""
Print the documentation then perform the demonstration(s).
"""
print(plain(doc(static_route_delete)))
print('Determine which devices are capable.')
print('inventory_static_route()')
inventory = inventory_static_route()
print_table(inventory, headers='device-name')
if not inventory:
print("There are no 'static route' capable devices. Demonstration cancelled.")
else:
print()
for device_name in inventory:
print('static_route_list(%s)' % device_name)
route_list = static_route_list(device_name)
print_table(route_list, headers='destination-network')
print()
if route_list:
demonstrate_one(device_name, route_list[0])
if len(route_list) > 1:
demonstrate_all(device_name)
return EX_OK
print("There are no devices with a 'static route' configured. Demonstration cancelled.")
return EX_TEMPFAIL
示例6: main
def main():
''' Select a device and demonstrate.'''
print(plain(doc(acl_apply_packet_filter)))
inventory = inventory_acl()
if not inventory:
print('There are no ACL capable devices to examine. Demonstration cancelled.')
else:
for device_name in inventory:
mgmt_name = management_interface(device_name)
acl_names = acl_list(device_name)
if not acl_names:
print('Skip device with no ACLs: ', device_name)
continue
else:
random.shuffle(acl_names)
acl_name = acl_names[0]
for ic in interface_configuration_tuple(device_name):
if ic.name == mgmt_name:
continue
print('Consider %s %s in=%s, out=%s' % (device_name, ic.name, ic.packet_filter_inbound, ic.packet_filter_outbound))
if not ic.packet_filter_outbound:
demonstrate(device_name, ic.name, 'outbound', acl_name)
return EX_OK
if not ic.packet_filter_inbound:
demonstrate(device_name, ic.name, 'inbound', acl_name)
return EX_OK
print('There are no network interfaces available to apply an ACL. Demonstration cancelled.')
return EX_TEMPFAIL
示例7: main
def main():
"""
Print the function documentation then demonstrate the function usage.
"""
print(plain(doc(inventory_static_route)))
return EX_OK if demonstrate() else EX_TEMPFAIL
示例8: main
def main():
print(plain(doc(device_dismount)))
for device_name in inventory_mounted():
demonstrate(device_name)
return EX_OK
print('There are no mounted devices to dismount. Demonstration cancelled.')
return EX_TEMPFAIL
示例9: main
def main():
''' Document and demonstrate the function.'''
print(plain(doc(inventory_static_route)))
if demonstrate():
return os.EX_OK
else:
return os.EX_TEMPFAIL
示例10: main
def main():
''' Select a device and demonstrate.'''
print(plain(doc(management_interface)))
for device_name in inventory_mounted():
demonstrate(device_name)
return os.EX_OK
print("There are no suitable network devices. Demonstration cancelled.")
return os.EX_TEMPFAIL
示例11: main
def main():
print(plain(doc(connected)))
device_names = inventory_mounted()
if not device_names:
print('There are no devices mounted on the Controller.')
else:
device_name = device_names[0]
print('is connected(%s):' % device_name, connected(device_name))
示例12: main
def main():
print(plain(doc(mounted)))
device_names = settings.config['network_device'].keys()
if not device_names:
print('There are no devices configured in the settings.')
else:
device_name = next(iter(device_names))
print('is mounted(%s):' % device_name, mounted(device_name))
示例13: main
def main():
""" Select a device and demonstrate."""
print(plain(doc(device_control)))
print("DeviceControl fields:", *DeviceControl._fields, sep="\n\t", end="\n\n")
for device_name in inventory_mounted():
demonstrate(device_name)
return EX_OK
print("There are no suitable network devices. Demonstration cancelled.")
return EX_TEMPFAIL
示例14: main
def main():
''' Select a device and demonstrate.'''
print(plain(doc(interface_names)))
mounted_list = inventory_mounted()
connected_list = inventory_connected()
device_list = list(set(connected_list) & set(mounted_list))
for device_name in device_list:
return demonstrate(device_name)
print('There are no mounted, connected devices to examine. Demonstration cancelled.')
示例15: test03_pyfunc_doc
def test03_pyfunc_doc(self):
"""Help on a generated pyfunc used to crash."""
import cppyy, distutils, pydoc, sys
cppyy.add_include_path(distutils.sysconfig_get_python_inc())
if sys.hexversion < 0x3000000:
cppyy.cppdef("#undef _POSIX_C_SOURCE")
cppyy.cppdef("#undef _XOPEN_SOURCE")
else:
cppyy.cppdef("#undef slots") # potentially pulled in by Qt/xapian.h
cppyy.cppdef("""#include "Python.h"
long py2long(PyObject* obj) { return PyLong_AsLong(obj); }""")
pydoc.doc(cppyy.gbl.py2long)
assert 1 == cppyy.gbl.py2long(1)