-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsrg_converter.py
More file actions
26 lines (22 loc) · 998 Bytes
/
tsrg_converter.py
File metadata and controls
26 lines (22 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
def convert_tsrg_to_srg(tsrg_path, srg_path):
with open(tsrg_path, 'r') as f:
lines = f.readlines()
output = []
current_class = ""
for line in lines:
if not line.startswith('\t'):
parts = line.strip().split()
if len(parts) >= 2:
current_class = parts[0]
output.append(f"CL: {parts[0]} {parts[1]}")
else:
parts = line.strip().split()
if len(parts) == 2: # Field
output.append(f"FD: {current_class}/{parts[0]} {current_class}/{parts[1]}")
elif len(parts) == 3: # Method
output.append(f"MD: {current_class}/{parts[0]} {parts[1]} {current_class}/{parts[2]} {parts[1]}")
with open(srg_path, 'w') as f:
f.write('\n'.join(output))
# Chạy chuyển đổi
convert_tsrg_to_srg('conf/joined.tsrg', 'conf/joined.srg')
print("Đã chuyển đổi thành công sang joined.srg!")