-
Notifications
You must be signed in to change notification settings - Fork 0
/
translate_std.py
46 lines (41 loc) · 1.25 KB
/
translate_std.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
import sys
import os
import main
macos = "MacOs"
other = "Other"
if sys.platform.startswith("win32"):
include_path = os.path.expandvars("%programfiles%/imhex/includes/std/")
elif sys.platform.startswith("darwin"):
include_path = macos
else:
include_path = other
if include_path == macos:
raise Exception("""
Hexpyt doesn't know where MacOs's imhex std include path is.
To fix it, change line 10 of translate_std.py
from
"include_path = macos"
to
"include_path = '<The include path goes here>'"
""")
elif include_path == other:
raise Exception("""
Hexpyt doesn't know where your OS's imhex std include path is.
To fix it, change line 12 of translate_std.py
from
"include_path = other"
to
"include_path = '<The include path goes here>'"
""")
def translate_std_files(target_dir: str):
if not (target_dir.endswith("/") or target_dir.endswith("\\")):
target_dir = target_dir + "/"
try:
os.listdir(target_dir)
except FileNotFoundError:
os.mkdir(target_dir)
std = os.listdir(include_path)
for file in std:
main.translate_file(include_path+file, target_dir+file.replace(".pat", ".py"))
if __name__ == "__main__":
translate_std_files("hexpat_std____/")