-
Notifications
You must be signed in to change notification settings - Fork 49
/
generate-directories.py
executable file
·60 lines (42 loc) · 1.21 KB
/
generate-directories.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
import requests
import json
import sys
import os
from pathlib import Path
slugs = set()
currentvrturl = "https://raw.githubusercontent.com/bugcrowd/vulnerability-rating-taxonomy/master/vulnerability-rating-taxonomy.json"
basedir = "templates"
vrtdata = requests.get(currentvrturl)
if vrtdata.status_code == 200:
data = json.loads(vrtdata.text)
def printChildren(category, parentstring):
if parentstring == "":
parentstring = category['id']
else:
parentstring = parentstring + '/' + category['id']
slugs.add(parentstring)
try:
children = category['children']
except:
return
for child in children:
printChildren(child, parentstring) # recursive
for category in data['content']:
try:
children = category['children']
except:
continue
for child in category['children']:
printChildren(category, "")
# change dirs to `templates`
os.chdir(basedir)
for slug in sorted(slugs):
#print(slug)
try:
os.mkdir(slug)
# Make sure we have a .gitkeep in the directory
gitkeep = "{}/.gitkeep".format(slug)
Path(gitkeep).touch()
except OSError as e:
pass