papermario/tools/smallest_with_symbol.py

32 lines
900 B
Python
Raw Normal View History

2021-01-13 11:48:54 +01:00
#!/usr/bin/python3
import argparse
import os
import re
script_dir = os.path.dirname(os.path.realpath(__file__))
root_dir = script_dir + "/../"
src_dir = root_dir + "src/"
asm_dir = root_dir + "asm/"
symbol = "gMasterGfxPos"
smallest_file = None
smallest_len = 1000
for root, dirs, files in os.walk(asm_dir):
for f_name in files:
2021-01-15 02:20:04 +01:00
if f_name.endswith(".s") and len(f_name) < 20 and f_name not in ["func_8024F768.s", "func_800271A0.s", "func_80240448_B141B8.s"]:
2021-01-13 11:48:54 +01:00
f_path = os.path.join(root, f_name)
with open(f_path) as f:
f_text = f.read()
if symbol in f_text:
num_lines = len(f_text.split("\n"))
if num_lines <= smallest_len:
print(f"{f_name}: {int(num_lines)}")
smallest_len = num_lines
smallest_file = f_name
print("\n" + smallest_file)