Last active
February 27, 2022 07:38
-
-
Save justin3737/fa4abe77e5b15e0765ee57592e9fb8f1 to your computer and use it in GitHub Desktop.
Revisions
-
justin3737 revised this gist
May 4, 2018 . 1 changed file with 16 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,33 +5,36 @@ import re # ------------------- Define ------------------- pat = '[a-zA-Z]+' xmlTags = ['String', 'value', 'string'] # ------------------- Use lib ------------------- d = enchant.Dict("en_US") # ------------------- Load whitelist ------------------- add_dict = open("exception.txt","r").readlines() for line in add_dict: d.add(line) # ------------------- Load XML ------------------- #DOMTree = xml.dom.minidom.parse("StringTable.xml") DOMTree = xml.dom.minidom.parse("MSReportTemplates.resx") arrData = [] for tages in xmlTags: arrData += DOMTree.getElementsByTagName(tages) if len( arrData ) > 0: for v in arrData: try: if v.childNodes[0].data is not None: line = re.findall(pat, v.childNodes[0].data) else: line = v.attributes['DisplayName'].value for x in range(len(line)): if d.check(line[x]) is False: print(line[x]) except IndexError: print('------------------- Parse L10N XML file error.------------------- ') # ------------------- Load JS ------------------- with open('L10N.update.js') as dataFile: data = dataFile.read() obj = js2py.eval_js(data) @@ -41,5 +44,4 @@ all = re.findall(pat, obj[key]) for x in range(len(all)): if d.check(all[x]) == False: print(all[x]) -
justin3737 revised this gist
May 3, 2018 . No changes.There are no files selected for viewing
-
justin3737 revised this gist
Apr 20, 2018 . 1 changed file with 7 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import re # ------------------- Define ------------------- pat = '[a-zA-Z]+' xmlTags = ['value', 'string'] #讀取XML的標籤 # ------------------- 使用字典lib ------------------- d = enchant.Dict("en_US") @@ -17,17 +17,19 @@ # ------------------- 讀取XML ------------------- DOMTree = xml.dom.minidom.parse("MSReportTemplates.en-US.resx") arrData = [] for tages in xmlTags: arrData += DOMTree.getElementsByTagName(tages) if len( arrData ) > 0 : for v in arrData: try: all = re.findall(pat, v.childNodes[0].data) for x in range(len(all)): if d.check(all[x]) == False: print(all[x]) except IndexError: print('------------------- Parse L10N XML file error.------------------- ') # ------------------- 讀取JS ------------------- with open('L10N.update.js') as dataFile: -
justin3737 revised this gist
Apr 20, 2018 . 1 changed file with 33 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,43 @@ import enchant from xml.dom.minidom import parse import xml.dom.minidom import js2py import re # ------------------- Define ------------------- pat = '[a-zA-Z]+' xmlTags = ['value', 'string'] # ------------------- 使用字典lib ------------------- d = enchant.Dict("en_US") # ------------------- 讀取白名單 ------------------- add_dict = open("exception.txt","r").readlines() for line in add_dict: d.add(line) # ------------------- 讀取XML ------------------- DOMTree = xml.dom.minidom.parse("MSReportTemplates.en-US.resx") values = DOMTree.getElementsByTagName("value") if len( values ) > 0 : for v in values: try: all = re.findall(pat, v.childNodes[0].data) for x in range(len(all)): if d.check(all[x]) == False: print(all[x]) except IndexError: print('Parse L10N XML file error.') # ------------------- 讀取JS ------------------- with open('L10N.update.js') as dataFile: data = dataFile.read() obj = js2py.eval_js(data) dataFile.close() for key in obj: all = re.findall(pat, obj[key]) for x in range(len(all)): if d.check(all[x]) == False: print(all[x]) -
justin3737 created this gist
Apr 20, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ import re pat = '[a-zA-Z]+' d = enchant.Dict("en_US") add_dict = open("C:\exception.txt","r").readlines() for line in add_dict: d.add(line) js = open("C:\l10n.exceptionModal.js","r").readlines()[2:100] d.add("udp") for line in js: all = re.findall(pat, line) for x in range(len(all)): if d.check(all[x]) == False: print all[x]