def traverse(roots, parent='', verbose=False):
"""
Recursive call which also handles printing output.
:param api: The falcon.API or callable that returns an instance to look at.
:type api: falcon.API or callable
:param parent: The parent uri path to the current iteration.
:type parent: str
:param verbose: If the output should be verbose.
:type verbose: bool
"""
for root in roots:
if root.method_map:
print('->', parent + '/' + root.raw_segment)
if verbose:
for method, func in root.method_map.items():
if func.__name__ != 'method_not_allowed':
if isinstance(func, partial):
real_func = func.func
else:
real_func = func
source_file = inspect.getsourcefile(real_func)
print('-->{0} {1}:{2}'.format(
method,
source_file,
source_file[1]
))
if root.children:
traverse(root.children, parent + '/' + root.raw_segment, verbose)
评论列表
文章目录