You've already forked Microtransactions64
mirror of
https://github.com/Print-and-Panic/Microtransactions64.git
synced 2026-01-21 10:17:19 -08:00
fixlights: added support for ripgrep (#802)
This commit is contained in:
@@ -1,21 +1,37 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import sys, subprocess, re
|
import sys, subprocess, re, shutil
|
||||||
|
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
print(f"Usage: {sys.argv[0]} [folder to search]")
|
print(f"Usage: {sys.argv[0]} [folder to search]")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
lightFiles = set()
|
lightFiles = set()
|
||||||
|
has_rg = shutil.which("rg") is not None
|
||||||
|
|
||||||
|
def make_search_cmd(regex, include = None):
|
||||||
|
cmd = None
|
||||||
|
if has_rg:
|
||||||
|
cmd = f"rg -lF {regex}"
|
||||||
|
else:
|
||||||
|
cmd = f"grep -Rl {regex}"
|
||||||
|
|
||||||
|
if include:
|
||||||
|
if has_rg:
|
||||||
|
cmd += f" -g {include}"
|
||||||
|
else:
|
||||||
|
cmd += f" --include {include}"
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
|
||||||
# The original command that was run across the entire repo to convert all assets
|
# The original command that was run across the entire repo to convert all assets
|
||||||
# cmds = ("grep -Rl \"gsSPSetLight\" levels actors bin","grep -Rl \"gsSPLight\" levels actors bin","grep -Rl \"Lights1\" levels actors bin")
|
# cmds = ("grep -Rl \"gsSPSetLight\" levels actors bin","grep -Rl \"gsSPLight\" levels actors bin","grep -Rl \"Lights1\" levels actors bin")
|
||||||
|
|
||||||
# Operate on the folder passed as an argument to this program
|
# Operate on the folder passed as an argument to this program
|
||||||
cmds = [
|
cmds = [
|
||||||
f"grep -Rl \"gsSPSetLight\" {sys.argv[1]}",
|
make_search_cmd(f"\"gsSPSetLight\" {sys.argv[1]}"),
|
||||||
f"grep -Rl \"gsSPLight\" {sys.argv[1]}",
|
make_search_cmd(f"\"gsSPLight\" {sys.argv[1]}"),
|
||||||
f"grep -Rl \"Lights1\" {sys.argv[1]}"
|
make_search_cmd(f"\"Lights1\" {sys.argv[1]}")
|
||||||
]
|
]
|
||||||
|
|
||||||
for cmd in cmds:
|
for cmd in cmds:
|
||||||
@@ -135,8 +151,7 @@ for file in lightFiles:
|
|||||||
def get_texscroll_files():
|
def get_texscroll_files():
|
||||||
mat_grep_commands = []
|
mat_grep_commands = []
|
||||||
for mat in material_deltas.keys():
|
for mat in material_deltas.keys():
|
||||||
print("grep -Rl \"segmented_to_virtual(" + re.escape(mat) + f"\" {sys.argv[1]}**/texscroll.inc.c")
|
mat_grep_commands.append(make_search_cmd("\"segmented_to_virtual(" + re.escape(mat) + rf"\" {sys.argv[1]}", "\"*texscroll*\""))
|
||||||
mat_grep_commands.append("grep -Rl \"segmented_to_virtual(" + re.escape(mat) + rf"\" {sys.argv[1]} --include \*texscroll*")
|
|
||||||
|
|
||||||
texscroll_files = set()
|
texscroll_files = set()
|
||||||
for cmd in mat_grep_commands:
|
for cmd in mat_grep_commands:
|
||||||
|
|||||||
Reference in New Issue
Block a user