print_routes.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码
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':
                        print('-->{0} {1}:{2}'.format(
                            method,
                            inspect.getsourcefile(func),
                            inspect.getsourcelines(func)[1]))
        if root.children:
            traverse(root.children, parent + '/' + root.raw_segment, verbose)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号