改写战斗中替换group的逻辑
This commit is contained in:
commit
7f89eb0db8
3890 changed files with 82290 additions and 0 deletions
41
extract_restype.py
Normal file
41
extract_restype.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
from pathlib import Path
|
||||
|
||||
res_path_name = "mower/resources/"
|
||||
res_path = Path(res_path_name)
|
||||
|
||||
data = "from typing import Literal\n\nRes = Literal[\n"
|
||||
references = {}
|
||||
|
||||
for i in sorted(res_path.glob("**/*.png")):
|
||||
res_name = i.as_posix()
|
||||
res_name = res_name.replace(res_path_name, "")
|
||||
res_name = res_name.replace(".png", "")
|
||||
data += f' "{res_name}",\n'
|
||||
references[res_name] = []
|
||||
|
||||
data += "]\n"
|
||||
|
||||
with open("mower/utils/typealias/res.py", "w", encoding="utf-8") as f:
|
||||
f.write(data)
|
||||
|
||||
for py_file in sorted(Path("mower").glob("**/*.py")):
|
||||
posix_path = py_file.as_posix()
|
||||
if posix_path in [
|
||||
"mower/utils/typealias/res.py",
|
||||
"mower/utils/recognize/data.py",
|
||||
]:
|
||||
continue
|
||||
with py_file.open("r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
for name, matches in references.items():
|
||||
if f'"{name}"' in content:
|
||||
matches.append(posix_path)
|
||||
|
||||
for name, matches in references.items():
|
||||
if len(matches) > 0:
|
||||
print(name)
|
||||
for m in matches:
|
||||
print(f" {m}")
|
||||
for name, matches in references.items():
|
||||
if len(matches) == 0:
|
||||
print(f"[WARN]{name}")
|
Loading…
Add table
Add a link
Reference in a new issue