-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathroutekit.py
More file actions
31 lines (25 loc) · 871 Bytes
/
Copy pathroutekit.py
File metadata and controls
31 lines (25 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Copyright (c) 2014, Rui Carmo
Description: Bottle-specific utility functions
License: MIT (see LICENSE.md for details)
"""
import os
import sys
import logging
import json
log = logging.getLogger()
def inspect_routes(app):
for route in app.routes:
if 'mountpoint' in route.config:
prefix = route.config['mountpoint']['prefix']
subapp = route.config['mountpoint']['target']
for prefixes, route in inspect_routes(subapp):
yield [prefix] + prefixes, route
else:
yield [], route
def dump_routes(app):
for prefixes, route in inspect_routes(app):
abs_prefix = '/'.join(part for p in prefixes for part in p.split('/'))
log.warn("Prefix:'%s' Route:'%s' [%s] %s" % (abs_prefix, route.rule, route.method, route.callback))