| OLD | NEW |
| 1 # coding: utf-8 | 1 # coding: utf-8 |
| 2 | 2 |
| 3 # This file is part of the Adblock Plus web scripts, | 3 # This file is part of the Adblock Plus web scripts, |
| 4 # Copyright (C) 2006-2014 Eyeo GmbH | 4 # Copyright (C) 2006-2014 Eyeo GmbH |
| 5 # | 5 # |
| 6 # Adblock Plus is free software: you can redistribute it and/or modify | 6 # Adblock Plus is free software: you can redistribute it and/or modify |
| 7 # it under the terms of the GNU General Public License version 3 as | 7 # it under the terms of the GNU General Public License version 3 as |
| 8 # published by the Free Software Foundation. | 8 # published by the Free Software Foundation. |
| 9 # | 9 # |
| 10 # Adblock Plus is distributed in the hope that it will be useful, | 10 # Adblock Plus is distributed in the hope that it will be useful, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 result = { | 58 result = { |
| 59 'extensionID': metadata.get('general', 'id'), | 59 'extensionID': metadata.get('general', 'id'), |
| 60 'version': version, | 60 'version': version, |
| 61 'compat': [] | 61 'compat': [] |
| 62 } | 62 } |
| 63 for key, value in KNOWN_APPS.iteritems(): | 63 for key, value in KNOWN_APPS.iteritems(): |
| 64 if metadata.has_option('compat', key): | 64 if metadata.has_option('compat', key): |
| 65 minVersion, maxVersion = metadata.get('compat', key).split('/') | 65 minVersion, maxVersion = metadata.get('compat', key).split('/') |
| 66 result['compat'].append({'id': value, 'minVersion': minVersion, 'maxVers
ion': maxVersion}) | 66 result['compat'].append({'id': value, 'minVersion': minVersion, 'maxVers
ion': maxVersion}) |
| 67 return result | 67 return result |
| 68 elif repo.type == 'ie': |
| 69 return { |
| 70 'name': repo.name, |
| 71 'version': version |
| 72 } |
| 68 else: | 73 else: |
| 69 raise Exception('unknown repository type %r' % repo.type) | 74 raise Exception('unknown repository type %r' % repo.type) |
| 70 | 75 |
| 71 def writeUpdateManifest(links): | 76 def writeUpdateManifest(links): |
| 72 """ | 77 """ |
| 73 writes an update manifest for all extensions and Android apps | 78 writes an update manifest for all extensions and Android apps |
| 74 """ | 79 """ |
| 75 | 80 |
| 76 extensions = {'gecko': [], 'android': [], 'safari': []} | 81 extensions = {'gecko': [], 'android': [], 'safari': [], 'ie': []} |
| 77 for repo in Configuration.getRepositoryConfigurations(): | 82 for repo in Configuration.getRepositoryConfigurations(): |
| 78 if repo.type not in extensions or not links.has_section(repo.repositoryName)
: | 83 if repo.type not in extensions or not links.has_section(repo.repositoryName)
: |
| 79 continue | 84 continue |
| 80 data = readMetadata(repo, links.get(repo.repositoryName, 'version')) | 85 data = readMetadata(repo, links.get(repo.repositoryName, 'version')) |
| 81 data['updateURL'] = links.get(repo.repositoryName, 'downloadURL') | 86 data['updateURL'] = links.get(repo.repositoryName, 'downloadURL') |
| 82 if data['updateURL'].startswith(repo.downloadsURL): | 87 if data['updateURL'].startswith(repo.downloadsURL): |
| 83 data['updateURL'] += "?update" | 88 data['updateURL'] += "?update" |
| 84 extensions[repo.type].append(data) | 89 extensions[repo.type].append(data) |
| 85 | 90 |
| 86 if len(extensions['android']) > 1: | 91 if len(extensions['android']) > 1: |
| 87 print >>sys.stderr, 'Warning: more than one Android app defined, update mani
fest only works for one' | 92 print >>sys.stderr, 'Warning: more than one Android app defined, update mani
fest only works for one' |
| 88 | 93 |
| 89 for repoType in extensions.iterkeys(): | 94 for repoType in extensions.iterkeys(): |
| 90 manifestPath = get_config().get('extensions', '%sUpdateManifestPath' % repoT
ype) | 95 manifestPath = get_config().get('extensions', '%sUpdateManifestPath' % repoT
ype) |
| 91 template = get_template(get_config().get('extensions', '%sUpdateManifest' %
repoType)) | 96 template = get_template(get_config().get('extensions', '%sUpdateManifest' %
repoType)) |
| 92 template.stream({'extensions': extensions[repoType]}).dump(manifestPath) | 97 template.stream({'extensions': extensions[repoType]}).dump(manifestPath) |
| 93 | 98 |
| 94 def updateUpdateManifests(): | 99 def updateUpdateManifests(): |
| 95 """ | 100 """ |
| 96 updates all update manifests with the current versions | 101 updates all update manifests with the current versions |
| 97 """ | 102 """ |
| 98 | 103 |
| 99 parser = SafeConfigParser() | 104 parser = SafeConfigParser() |
| 100 getDownloadLinks(parser) | 105 getDownloadLinks(parser) |
| 101 writeUpdateManifest(parser) | 106 writeUpdateManifest(parser) |
| 102 | 107 |
| 103 if __name__ == "__main__": | 108 if __name__ == "__main__": |
| 104 updateUpdateManifests() | 109 updateUpdateManifests() |
| OLD | NEW |