mirror of
https://github.com/an-anime-team/sleepy-launcher.git
synced 2024-11-21 20:27:35 +03:00
Update fluentscan.py
added: initial error checking support, detecting of unused entries
This commit is contained in:
parent
f9bf0accf8
commit
2739006b52
1 changed files with 33 additions and 1 deletions
|
@ -5,6 +5,17 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
|
||||
valid_args=["diff","unused"]
|
||||
|
||||
if len(sys.argv)<3 or len(sys.argv) == 0:
|
||||
print("missing arguments")
|
||||
sys.exit()
|
||||
|
||||
if sys.argv[2] not in valid_args:
|
||||
print(f"invalid argument:{sys.argv[2]}")
|
||||
sys.exit()
|
||||
|
||||
path = "assets/locales/" + sys.argv[1] + "/"
|
||||
|
||||
|
@ -48,8 +59,27 @@ for filename in os.listdir("assets/locales/en"):
|
|||
|
||||
# TODO: why modified is not used?
|
||||
added, removed, modified, same = dict_compare(expected, expected2)
|
||||
if sys.argv[2] == "unused" or sys.argv[2] == "missing":
|
||||
files = glob.glob("src/" + '/**/*.rs', recursive=True)
|
||||
used=[]
|
||||
for i in files:
|
||||
with open(i,"r") as script:
|
||||
text=script.read()
|
||||
if sys.argv[2] == "unused":
|
||||
for j in expected:
|
||||
if '"'+j+'"' in text:
|
||||
used.append(j)
|
||||
#elif sys.argv[2] == "missing":
|
||||
#for j in text.split():
|
||||
#find all cases of tr(
|
||||
|
||||
for i in expected:
|
||||
if i not in used:
|
||||
print(f"{i} is not used ({locale_file.name})")
|
||||
|
||||
if added or removed or same:
|
||||
continue
|
||||
|
||||
if (added or removed or same) and sys.argv[2] == "diff":
|
||||
print(f"[{created_locale.name[15:]}]")
|
||||
|
||||
if added:
|
||||
|
@ -72,3 +102,5 @@ for filename in os.listdir("assets/locales/en"):
|
|||
print(f" {i} = {expected[i]}")
|
||||
|
||||
print("")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue