-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path__main__.py
78 lines (63 loc) · 2.06 KB
/
__main__.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import json
import logging
import pathlib
import requests
from . import Generator
from . import Parser
logging.basicConfig(level=logging.INFO)
session = requests.Session()
session.headers = {"Cache-Control": "no-cache"}
with open(str(pathlib.Path(__file__).parent / "config.json"), "r") as f:
config = json.loads(f.read())
additions = {}
for addition_key in config["additions"].keys():
addition_value = config["additions"][addition_key]
for addition in addition_value:
additions[addition] = addition_key
base_file_url = "https://raw.githubusercontent.com/{}/{}/master/".format(
config["owner"], config["repo"]
)
tree = session.get(
"https://api.github.com/repos/{}/{}/git/trees/master?recursive=1".format(
config["owner"], config["repo"]
),
)
tree = tree.json()["tree"]
files = []
for file in tree:
if "developers" not in file["path"]:
continue
if "README.md" in file["path"] or "SUMMARY.md" in file["path"]:
continue
if not file["path"].endswith(".md"):
continue
if "developers/tables/" in file["path"]:
files.append({"path": file["path"], "is_table": True})
elif "developers/classes/" in file["path"]:
files.append({"path": file["path"], "is_table": False})
else:
for key in additions.keys():
if key in file["path"]:
files.append(
{
"path": file["path"],
"is_table": True,
"table_name": additions[key],
}
)
for file in files:
if (
"c_base" in file["path"] or "IGameEvent" in file["path"] or "ConVar" in file["path"]
): # TODO: Fix globalname searcher to avoid this checks
continue
tbl_name = None
if "table_name" in file.keys():
tbl_name = file["table_name"]
Parser.parse_content(
file["path"],
session.get(base_file_url + file["path"]).text,
file["is_table"],
tbl_name,
)
Generator.get().generate()
Generator.get().write("output.json")