forked from mariopartyrd/marioparty2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport_symbols_to_pj64sym.py
executable file
·40 lines (32 loc) · 1.37 KB
/
export_symbols_to_pj64sym.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
import subprocess
def parse_and_format(input_file_path, output_file_path):
with open(input_file_path, 'r') as file:
lines = file.readlines()
formatted_lines = []
for line in lines:
if line.strip() == '//data and bss':
break
parts = line.split(' = ')
if len(parts) != 2:
continue
name = parts[0].strip()
address = parts[1].split(';')[0].strip()
address = address.replace('0x', '') # Strip the '0x' prefix
formatted_line = f"{address},code,{name}"
formatted_lines.append(formatted_line)
with open(output_file_path, 'w') as file:
file.write('\n'.join(formatted_lines))
def move_file(source, destination):
try:
# Using the shell mode to handle paths with spaces and special characters
subprocess.run(f'cp "{source}" "{destination}"', shell=True, check=True)
subprocess.run(f'rm "{source}"', shell=True, check=True) # Remove the original file after copying
print(f"File moved to {destination}")
except subprocess.CalledProcessError as e:
print(f"Error occurred: {e}")
# Specify the paths to your input and output files
input_file_path = 'symbol_addrs.txt'
output_file_path = 'MarioParty2.sym'
final_destination = ''
parse_and_format(input_file_path, output_file_path)
move_file(output_file_path, final_destination)