-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgen_pyi.py
65 lines (52 loc) · 1.9 KB
/
gen_pyi.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
import logging
import traceback
from pathlib import Path
from pyrx import Ap, Ax, Br, Db, Ed, Ge, Gi, Gs, Pl, Rx, Sm
from pyrx.doc_utils.misc import DocstringsManager, ReturnTypesManager
from pyrx.doc_utils.pyi_gen import gen_pyi
if "BRX" in Ap.Application.hostAPI():
from pyrx import Cv
from pyrx import Bim
from pyrx import Brx
def PyRxCmd_gen_pyi_brx():
try:
runBRX()
except Exception:
traceback.print_exc()
def PyRxCmd_gen_pyi():
try:
runARX()
except Exception:
traceback.print_exc()
def runBRX():
logging.basicConfig(filename="gen_pyi_brx.log", filemode="w", force=True)
PYI_DIR = Path(__file__).parent / "pyrx"
for module in (Ap, Br, Db, Ed, Ge, Gi, Gs, Pl, Rx, Sm, Ax, Cv, Bim, Brx):
res = gen_pyi(
module=module,
all_modules=(Ap, Br, Db, Ed, Ge, Gi, Gs, Pl, Rx, Sm, Ax, Cv, Bim, Brx),
docstrings=DocstringsManager.from_json(),
return_types=ReturnTypesManager.from_json(),
).gen()
with open(PYI_DIR / f"{module.__name__}.pyi", "w", encoding="utf-8") as f:
f.write(res)
def runARX():
logging.basicConfig(filename="gen_pyi.log", filemode="w", force=True)
PYI_DIR = Path(__file__).parent / "pyrx"
for module in (Ap, Ax, Br, Db, Ed, Ge, Gi, Gs, Pl, Rx, Sm):
res = gen_pyi(
module=module,
all_modules=(Ap, Br, Db, Ed, Ge, Gi, Gs, Pl, Rx, Sm, Ax),
docstrings=DocstringsManager.from_json(),
return_types=ReturnTypesManager.from_json(),
).gen()
with open(PYI_DIR / f"{module.__name__}.pyi", "w", encoding="utf-8") as f:
f.write(res)
def OnPyReload():
try:
import sys
to_remove = tuple(name for name in sys.modules if name.startswith("pyrx"))
for name in to_remove:
sys.modules.pop(name)
except Exception:
traceback.print_exc()