Also search for missing stringtable entries

This commit is contained in:
PabstMirror 2015-09-20 17:46:43 -05:00
parent 6773119f09
commit 5555eb195a
2 changed files with 58 additions and 34 deletions

View File

@ -9,7 +9,7 @@
<Czech>Nastavení Pozorovatele</Czech> <Czech>Nastavení Pozorovatele</Czech>
<Spanish>Ajustes de espectador</Spanish> <Spanish>Ajustes de espectador</Spanish>
</Key> </Key>
<Key ID="STR_ACE_Spectator_Settings_Descripton"> <Key ID="STR_ACE_Spectator_Settings_Description">
<English>Configure how the spectator system will operate by default.</English> <English>Configure how the spectator system will operate by default.</English>
<Polish>Skonfiguruj domyślne ustawienia obserwatora.</Polish> <Polish>Skonfiguruj domyślne ustawienia obserwatora.</Polish>
<Portuguese>Configura como o sistema de espectador operará por padrão.</Portuguese> <Portuguese>Configura como o sistema de espectador operará por padrão.</Portuguese>

View File

@ -20,11 +20,11 @@ ccb = ctypes.windll.user32.CloseClipboard
ga = ctypes.windll.kernel32.GlobalAlloc # Global Memory allocation ga = ctypes.windll.kernel32.GlobalAlloc # Global Memory allocation
gl = ctypes.windll.kernel32.GlobalLock # Global Memory Locking gl = ctypes.windll.kernel32.GlobalLock # Global Memory Locking
gul = ctypes.windll.kernel32.GlobalUnlock gul = ctypes.windll.kernel32.GlobalUnlock
GMEM_DDESHARE = 0x2000 GMEM_DDESHARE = 0x2000
def Get( ): def Get( ):
ocb(None) # Open Clip, Default task ocb(None) # Open Clip, Default task
pcontents = gcd(1) # 1 means CF_TEXT.. too lazy to get the token thingy ... pcontents = gcd(1) # 1 means CF_TEXT.. too lazy to get the token thingy ...
data = ctypes.c_char_p(pcontents).value data = ctypes.c_char_p(pcontents).value
#gul(pcontents) ? #gul(pcontents) ?
ccb() ccb()
@ -41,20 +41,10 @@ def Paste( data ):
ccb() ccb()
def getFunctions(filepath): def getFunctions(filepath):
selfmodule = (re.search('addons[\W]*([_a-zA-Z0-9]*)', filepath)).group(1) selfmodule = (re.search('addons[\W]*([_a-zA-Z0-9]*)', filepath)).group(1)
# print("Checking {0} from {1}".format(filepath,selfmodule)) # print("Checking {0} from {1}".format(filepath,selfmodule))
def pushClosing(t):
closingStack.append(closing.expr)
closing << Literal( closingFor[t[0]] )
def popClosing():
closing << closingStack.pop()
with open(filepath, 'r') as file: with open(filepath, 'r') as file:
content = file.read() content = file.read()
@ -65,16 +55,41 @@ def getFunctions(filepath):
srch = re.compile('EFUNC\(([_a-zA-Z0-9]*),([_a-zA-Z0-9]*)\)') srch = re.compile('EFUNC\(([_a-zA-Z0-9]*),([_a-zA-Z0-9]*)\)')
exfuncs = srch.findall(content) exfuncs = srch.findall(content)
exfuncs = sorted(set(exfuncs)) exfuncs = sorted(set(exfuncs))
allFuncs = [] fileFuncs = []
for func in modfuncs: for func in modfuncs:
allFuncs.append("ace_{0}_fnc_{1}".format(selfmodule,func)) fileFuncs.append("ace_{0}_fnc_{1}".format(selfmodule,func))
for exModule,func in exfuncs: for exModule,func in exfuncs:
allFuncs.append("ace_{0}_fnc_{1}".format(exModule, func)) fileFuncs.append("ace_{0}_fnc_{1}".format(exModule, func))
return allFuncs return fileFuncs
def getStrings(filepath):
selfmodule = (re.search('addons[\W]*([_a-zA-Z0-9]*)', filepath)).group(1)
# print("Checking {0} from {1}".format(filepath,selfmodule))
with open(filepath, 'r') as file:
content = file.read()
srch = re.compile('[^E][CL]STRING\(([_a-zA-Z0-9]*)\)')
modfuncs = srch.findall(content)
modfuncs = sorted(set(modfuncs))
srch = re.compile('[^E][CL]STRING\(([_a-zA-Z0-9]*)\)')
exfuncs = srch.findall(content)
exfuncs = sorted(set(exfuncs))
fileStrings = []
for func in modfuncs:
fileStrings.append("STR_ACE_{0}_{1}".format(selfmodule,func))
# for exModule,func in exfuncs:
# fileStrings.append("STR_ACE_{0}_{1}".format(exModule, func))
return fileStrings
def main(): def main():
print("#########################") print("#########################")
@ -82,30 +97,39 @@ def main():
print("#########################") print("#########################")
sqf_list = [] sqf_list = []
allFunctions = [] allFunctions = []
allStrings = []
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('-m','--module', help='only search specified module addon folder', required=False, default=".") parser.add_argument('-m','--module', help='only search specified module addon folder', required=False, default=".")
args = parser.parse_args() args = parser.parse_args()
for root, dirnames, filenames in os.walk('../addons' + '/' + args.module): for root, dirnames, filenames in os.walk('../addons' + '/' + args.module):
for filename in fnmatch.filter(filenames, '*.sqf'): for filename in fnmatch.filter(filenames, '*.sqf'):
sqf_list.append(os.path.join(root, filename)) sqf_list.append(os.path.join(root, filename))
for filename in fnmatch.filter(filenames, '*.cpp'):
sqf_list.append(os.path.join(root, filename))
for filename in fnmatch.filter(filenames, '*.hpp'):
sqf_list.append(os.path.join(root, filename))
for filename in sqf_list: for filename in sqf_list:
allFunctions = allFunctions + getFunctions(filename) allFunctions = allFunctions + getFunctions(filename)
for filename in sqf_list:
allStrings = allStrings + getStrings(filename)
testCode1 = "diag_log text '*********** Scaning for nil functions [count {0}]';".format(len(set(allFunctions)));
testCode2 = "{ if (isNil _x) then {systemChat format ['%1 is nil', _x]; diag_log text format ['%1 is nil', _x];}} forEach allFunctions;";
codeHeader = "diag_log text '*********** Scaning for nil functions [funcs {0} / strings {1}]';".format(len(set(allFunctions)), len(set(allStrings)))
outputCode = "{0} allFunctions = {1}; {2}".format(testCode1, list(set(allFunctions)), testCode2) codeFuncCheck = "{ if (isNil _x) then {systemChat format ['%1 is nil', _x]; diag_log text format ['%1 is nil', _x];}} forEach allFunctions;"
codeStringCheck = "{ if (!isLocalized _x) then {systemChat format ['%1 is not in stringtable', _x]; diag_log text format ['%1 is not in stringtable', _x];}} forEach allStrings;"
outputCode = "{0} allFunctions = {1}; allStrings = {2}; {3} {4}".format(codeHeader, list(set(allFunctions)), list(set(allStrings)), codeFuncCheck, codeStringCheck)
print(outputCode) print(outputCode)
Paste(outputCode); Paste(outputCode);
print ("") print ("")
print ("Copied to clipboard, total func count {0}".format(len(set(allFunctions)))) print ("Copied to clipboard, [funcs {0} / strings {1}]'".format(len(set(allFunctions)), len(set(allStrings))))
if __name__ == "__main__": if __name__ == "__main__":
main() main()