-
Notifications
You must be signed in to change notification settings - Fork 20
/
numpkg.py
44 lines (35 loc) · 1.3 KB
/
numpkg.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
#!/usr/bin/python
# Repackage cb2num.srg mappings to cb2numpkg.srg, with FML's repackaging to match runtime deobf
import sys, re
import srglib
def repackage(s, packageMap):
def getNewName(match):
className = match.group(1)
if not packageMap.has_key(className):
# from a time before packaging..
return "net/minecraft/src/"+className
else:
return packageMap[className] + "/" + className
return re.sub(r"net\/minecraft\/src/(\w+)", getNewName, s)
def main():
packageMap = srglib.readCSVMap("allpackages.csv")
for line in sys.stdin.readlines():
line = line.strip()
tokens = line.split(" ")
kind = tokens[0]
args = tokens[1:]
if kind == "PK:": # package
print line
elif kind == "CL:": # class
inName, outName = args
print kind, inName, repackage(outName, packageMap)
elif kind == "FD:": # field
inName, outName = args
print kind, inName, repackage(outName, packageMap)
elif kind == "MD:": # method
inName, inSig, outName, outSig = args
print kind, inName, inSig, repackage(outName, packageMap), repackage(outSig, packageMap)
else:
print line
if __name__ == "__main__":
main()