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

Side by Side Diff: sitescripts/extensions/utils.py

Issue 30017558: Noissue - Use latest stable AMO api (Closed) Base URL: https://hg.adblockplus.org/abpssembly/file/776cf4ca9d1d
Patch Set: Created Feb. 25, 2019, 9:03 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
« no previous file with comments | « no previous file | 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 file is part of the Adblock Plus web scripts, 1 # This file is part of the Adblock Plus web scripts,
2 # Copyright (C) 2006-present eyeo GmbH 2 # Copyright (C) 2006-present eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 except ExpatError as err: 270 except ExpatError as err:
271 exception = Exception('Error {0} while parsing xml:\n{1}\nfrom {2}' 271 exception = Exception('Error {0} while parsing xml:\n{1}\nfrom {2}'
272 .format(err, content, url)) 272 .format(err, content, url))
273 raise exception 273 raise exception
274 274
275 275
276 def _getMozillaDownloadLink(galleryID): 276 def _getMozillaDownloadLink(galleryID):
277 """ 277 """
278 gets download link for a Gecko add-on from the Mozilla Addons site 278 gets download link for a Gecko add-on from the Mozilla Addons site
279 """ 279 """
280 url = 'https://services.addons.mozilla.org/en-US/firefox/api/1/addon/%s' % _ urlencode(galleryID) 280 url = 'https://addons.mozilla.org/api/v3/addons/addon/' + galleryID
281 document = _parseXMLDocument(url) 281 with _urlopen(url) as data:
282 linkTags = document.getElementsByTagName('install') 282 result = json.load(data)
283 linkTag = linkTags[0] if len(linkTags) > 0 else None 283
284 versionTags = document.getElementsByTagName('version') 284 return (
285 versionTag = versionTags[0] if len(versionTags) > 0 else None 285 result['current_version']['files'][0]['url'],
286 if linkTag and versionTag and linkTag.firstChild and versionTag.firstChild: 286 result['current_version']['version']
287 return (linkTag.firstChild.data, versionTag.firstChild.data) 287 )
288 else:
289 return (None, None)
290 288
291 289
292 def _getLocalLink(repo): 290 def _getLocalLink(repo):
293 """ 291 """
294 gets the link for the newest download of an add-on in the local downloads 292 gets the link for the newest download of an add-on in the local downloads
295 repository 293 repository
296 """ 294 """
297 highestURL = None 295 highestURL = None
298 highestVersion = None 296 highestVersion = None
299 297
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 if not extensions: 395 if not extensions:
398 return 396 return
399 397
400 updates = {} 398 updates = {}
401 for extension in extensions: 399 for extension in extensions:
402 updates[extension['basename']] = { 400 updates[extension['basename']] = {
403 'url': extension['updateURL'], 401 'url': extension['updateURL'],
404 'version': extension['version'], 402 'version': extension['version'],
405 } 403 }
406 writeLibabpUpdateManifest(path, updates) 404 writeLibabpUpdateManifest(path, updates)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld