forked from Polygant/OpenCEX-backend
-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_urls.py
38 lines (27 loc) · 827 Bytes
/
get_urls.py
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
32
33
34
35
36
37
import os
import random
import time
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'exchange.settings')
import django
django.setup()
def main():
from django.conf import settings
from django.urls import URLPattern, URLResolver
urlconf = __import__(settings.ROOT_URLCONF, {}, {}, [''])
def list_urls(lis, acc=None):
if acc is None:
acc = []
if not lis:
return
l = lis[0]
if isinstance(l, URLPattern):
yield acc + [str(l.pattern)]
elif isinstance(l, URLResolver):
yield from list_urls(l.url_patterns, acc + [str(l.pattern)])
yield from list_urls(lis[1:], acc)
for p in list_urls(urlconf.urlpatterns):
print(''.join(p))
if __name__ == '__main__':
print('Start')
main()
print('Stop')