-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLuaDecompile.py
More file actions
32 lines (29 loc) · 998 Bytes
/
LuaDecompile.py
File metadata and controls
32 lines (29 loc) · 998 Bytes
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
#!/usr/bin/env python3
import os
import platform
import sys
from LuaCode import LUAFILEMAXSIZE
def ProcessFile(path:str)->None:
if os.path.isdir(path):
files = os.listdir(path)
for file in files: ProcessFile(os.path.join(path, file))
elif path.endswith('.lua'):
if os.path.getsize(path) > LUAFILEMAXSIZE: sys.exit(f'{path}文件太大无法转换。')
newpath = path.split('.')[0] + '_deCompile.' + path.split('.')[1]
if (os.system(f'java -jar unluac.jar "{path}">"{newpath}"')):
os.system(f'echo {path}错误')
os.system(f'rm -f "{newpath}')
else:
os.system(f'mv -f "{newpath}" "{path}"')
os.system(f'echo {path}')
if __name__ == '__main__':
try:
FilePaths = sys.argv[1:]
if len(FilePaths) == 0: raise Exception
except:
InputPaths = input('请输入文件路径或文件名(多文件以,隔开):')
FilePaths = InputPaths.split(',')
finally:
for FilePath in FilePaths:
ProcessFile(FilePath)
if platform.system() == 'Windows': os.system("pause")