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

Delta Between Two Patch Sets: updateRules.py

Issue 29337915: Issue 3748 - Update URL Fixer dependency on buildtools to revision c92cc4e4a338 and make it E10S-co… (Closed)
Left Patch Set: Created March 7, 2016, 8:19 p.m.
Right Patch Set: Even more bracket style adjustments Created March 14, 2016, 2:19 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « lib/typoRules.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 3
4 # This file is part of the URL Fixer, 4 # This file is part of the URL Fixer,
5 # Copyright (C) 2006-2016 Eyeo GmbH 5 # Copyright (C) 2006-2016 Eyeo GmbH
6 # 6 #
7 # URL Fixer is free software: you can redistribute it and/or modify 7 # URL Fixer is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 3 as 8 # it under the terms of the GNU General Public License version 3 as
9 # published by the Free Software Foundation. 9 # published by the Free Software Foundation.
10 # 10 #
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 if not domain in domains or domains[domain] < priority - maxPriority: 253 if not domain in domains or domains[domain] < priority - maxPriority:
254 domains[domain] = priority - maxPriority 254 domains[domain] = priority - maxPriority
255 255
256 # Fill up with "official" TLDs 256 # Fill up with "official" TLDs
257 getTLDs(domains, -maxPriority) 257 getTLDs(domains, -maxPriority)
258 258
259 rules['domain'] = {} 259 rules['domain'] = {}
260 getSuffixes(rules['domain'], domains) 260 getSuffixes(rules['domain'], domains)
261 261
262 def writeRules(rules): 262 def writeRules(rules):
263 path = os.path.join('defaults', 'typoRules.json') 263 path = os.path.join('chrome', 'content', 'typoRules.json')
264 file = codecs.open(path, 'rb', encoding='utf-8') 264 file = codecs.open(path, 'rb', encoding='utf-8')
265 data = file.read() 265 data = file.read()
266 file.close() 266 file.close()
267 267
268 marker = '// Automatically generated dictionaries' 268 marker = '// Automatically generated dictionaries'
269 markerIndex = data.find(marker) 269 markerIndex = data.find(marker)
270 if markerIndex < 0: 270 if markerIndex < 0:
271 raise Exception('Insertion marker not found in %s' % path) 271 raise Exception('Insertion marker not found in %s' % path)
272 data = data[0:markerIndex + len(marker)] + '\n' 272 data = data[0:markerIndex + len(marker)] + '\n'
273 data += ' ' + json.dumps(rules, ensure_ascii=False, sort_keys=True, separator s = (',', ':'))[1:-1] + '\n}\n' 273 data += ' ' + json.dumps(rules, ensure_ascii=False, sort_keys=True, separator s = (',', ':'))[1:-1] + '\n}\n'
274 274
275 file = codecs.open(path, 'wb', encoding='utf-8') 275 file = codecs.open(path, 'wb', encoding='utf-8')
276 file.write(data) 276 file.write(data)
277 file.close() 277 file.close()
278 278
279 def updateRules(): 279 def updateRules():
280 rules = {} 280 rules = {}
281 rules['domainReferrals'] = domainReferrals 281 rules['domainReferrals'] = domainReferrals
282 updateSchemes(rules) 282 updateSchemes(rules)
283 updateDomains(rules) 283 updateDomains(rules)
284 writeRules(rules) 284 writeRules(rules)
285 285
286 if __name__ == "__main__": 286 if __name__ == "__main__":
287 updateRules() 287 updateRules()
LEFTRIGHT

Powered by Google App Engine
This is Rietveld