Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: updateRules.py

Issue 8554013: Renamed necessary components for ABP integration (Closed)
Patch Set: Created Oct. 10, 2012, 11:49 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« chrome/locale/en-US/typoOptions.dtd ('K') | « lib/typoRules.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 3
4 # This Source Code is subject to the terms of the Mozilla Public License 4 # This Source Code is subject to the terms of the Mozilla Public License
5 # version 2.0 (the "License"). You can obtain a copy of the License at 5 # version 2.0 (the "License"). You can obtain a copy of the License at
6 # http://mozilla.org/MPL/2.0/. 6 # http://mozilla.org/MPL/2.0/.
7 7
8 """ 8 """
9 Update the dictionaries in the rules 9 Update the dictionaries in the rules
10 ==================================== 10 ====================================
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 if not domain in domains or domains[domain] < priority - maxPriority: 328 if not domain in domains or domains[domain] < priority - maxPriority:
329 domains[domain] = priority - maxPriority 329 domains[domain] = priority - maxPriority
330 330
331 # Fill up with "official" TLDs 331 # Fill up with "official" TLDs
332 getTLDs(domains, -maxPriority) 332 getTLDs(domains, -maxPriority)
333 333
334 rules['domain'] = {} 334 rules['domain'] = {}
335 getSuffixes(rules['domain'], domains) 335 getSuffixes(rules['domain'], domains)
336 336
337 def writeRules(rules): 337 def writeRules(rules):
338 path = os.path.join('defaults', 'rules.json') 338 path = os.path.join('defaults', 'typoRules.json')
339 file = codecs.open(path, 'rb', encoding='utf-8') 339 file = codecs.open(path, 'rb', encoding='utf-8')
340 data = file.read() 340 data = file.read()
341 file.close() 341 file.close()
342 342
343 marker = '// Automatically generated dictionaries' 343 marker = '// Automatically generated dictionaries'
344 markerIndex = data.find(marker) 344 markerIndex = data.find(marker)
345 if markerIndex < 0: 345 if markerIndex < 0:
346 raise Exception('Insertion marker not found in %s' % path) 346 raise Exception('Insertion marker not found in %s' % path)
347 data = data[0:markerIndex + len(marker)] + '\n' 347 data = data[0:markerIndex + len(marker)] + '\n'
348 data += ' ' + json.dumps(rules, ensure_ascii=False, sort_keys=True, separator s = (',', ':'))[1:-1] + '\n}\n' 348 data += ' ' + json.dumps(rules, ensure_ascii=False, sort_keys=True, separator s = (',', ':'))[1:-1] + '\n}\n'
349 349
350 file = codecs.open(path, 'wb', encoding='utf-8') 350 file = codecs.open(path, 'wb', encoding='utf-8')
351 file.write(data) 351 file.write(data)
352 file.close() 352 file.close()
353 353
354 def updateRules(): 354 def updateRules():
355 rules = {} 355 rules = {}
356 rules['domainReferrals'] = domainReferrals 356 rules['domainReferrals'] = domainReferrals
357 updateSchemes(rules) 357 updateSchemes(rules)
358 updateDomains(rules) 358 updateDomains(rules)
359 writeRules(rules) 359 writeRules(rules)
360 360
361 if __name__ == "__main__": 361 if __name__ == "__main__":
362 updateRules() 362 updateRules()
OLDNEW
« chrome/locale/en-US/typoOptions.dtd ('K') | « lib/typoRules.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld