-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathloadtools.py
More file actions
executable file
·45 lines (43 loc) · 1.25 KB
/
Copy pathloadtools.py
File metadata and controls
executable file
·45 lines (43 loc) · 1.25 KB
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
import os
import nethandler
import twc.psp
import twc.dsmarshal
import twccommon
import functools
import rsfix
import patches
def compilers(rs, unp = True):
ns = {"params": twccommon.Data()}
path = None
if os.path.exists(rs):
path = rs
elif nethandler.requestNetAssetExt(rs):
path = nethandler.requestNetAssetExt(rs)
if not path:
raise ValueError("rs file not found!")
with open(path, "r") as f:
data = f.read()
if unp:
data = patches.unprint(data)
rseval : str = twc.psp.evalRenderScript(data, ns)
#replace audiosequencer things
rseval = rsfix.fix(rseval)
return rseval
def fixsort(code: str) -> str:
#replaces the son of the devil (python 2 styled sorting)
finalcode = ""
working = code[:]
while True:
fn = working.find(".sort(")
if fn == -1:
finalcode += working
break
finalcode += working[:fn+6]
close = working.find(")", fn)
if close == -1:
raise ValueError("prod file is broken")
cmp = working[fn+6:close]
if cmp != "":
finalcode += f"key=functools.cmp_to_key({cmp})"
working = working[close:]
return finalcode.replace("Exception, e", "Exception as e")