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

Side by Side Diff: publicSuffixListUpdater.py

Issue 29350338: Issue 4382 - Use new syntax to catch exceptions in buildtools (Closed)
Patch Set: Created Aug. 30, 2016, 1:32 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « packagerChrome.py ('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 # This Source Code Form is subject to the terms of the Mozilla Public 1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this 2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 4
5 """ 5 """
6 Update the public suffix list 6 Update the public suffix list
7 ============================== 7 ==============================
8 8
9 This script generates a js array of public suffixes (http://publicsuffix.org/) 9 This script generates a js array of public suffixes (http://publicsuffix.org/)
10 """ 10 """
11 11
12 import os 12 import os
13 import urllib 13 import urllib
14 import json 14 import json
15 15
16 16
17 def urlopen(url, attempts=3): 17 def urlopen(url, attempts=3):
18 """ 18 """
19 Tries to open a particular URL, retries on failure. 19 Tries to open a particular URL, retries on failure.
20 """ 20 """
21 for i in range(attempts): 21 for i in range(attempts):
22 try: 22 try:
23 return urllib.urlopen(url) 23 return urllib.urlopen(url)
24 except IOError, e: 24 except IOError as e:
25 error = e 25 error = e
26 time.sleep(5) 26 time.sleep(5)
27 raise error 27 raise error
28 28
29 29
30 def getPublicSuffixList(): 30 def getPublicSuffixList():
31 """ 31 """
32 gets download link for a Gecko add-on from the Mozilla Addons site 32 gets download link for a Gecko add-on from the Mozilla Addons site
33 """ 33 """
34 suffixes = {} 34 suffixes = {}
(...skipping 16 matching lines...) Expand all
51 51
52 def updatePSL(baseDir): 52 def updatePSL(baseDir):
53 """ 53 """
54 writes the current public suffix list to js file in json format 54 writes the current public suffix list to js file in json format
55 """ 55 """
56 56
57 psl = getPublicSuffixList() 57 psl = getPublicSuffixList()
58 file = open(os.path.join(baseDir, 'lib', 'publicSuffixList.js'), 'w') 58 file = open(os.path.join(baseDir, 'lib', 'publicSuffixList.js'), 'w')
59 print >>file, 'var publicSuffixes = ' + json.dumps(psl, sort_keys=True, inde nt=4, separators=(',', ': ')) + ';' 59 print >>file, 'var publicSuffixes = ' + json.dumps(psl, sort_keys=True, inde nt=4, separators=(',', ': ')) + ';'
60 file.close() 60 file.close()
OLDNEW
« no previous file with comments | « packagerChrome.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld