LEFT | RIGHT |
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 return result | 85 return result |
86 return 0 | 86 return 0 |
87 | 87 |
88 class Configuration(object): | 88 class Configuration(object): |
89 """ | 89 """ |
90 This class represents the configuration settings for a single repository. | 90 This class represents the configuration settings for a single repository. |
91 Some of these properties come from the nightly config file and can be | 91 Some of these properties come from the nightly config file and can be |
92 changed (latestRevision), others come from the global config and are | 92 changed (latestRevision), others come from the global config and are |
93 read-only (repository, repositoryName, nightliesDirectory). | 93 read-only (repository, repositoryName, nightliesDirectory). |
94 """ | 94 """ |
95 | 95 def _defineProperty(name, local=False, type='', default=None): |
96 def _defineGlobalProperty(key): | 96 def getter(self): |
97 """ | 97 method = getattr(self.config, 'get' + type) |
98 Creates a property corresponding with a key in the config file | 98 key = '%s_%s' % (self.repositoryName, name) if local else name |
99 """ | 99 |
100 return property(lambda self: self.config.get('extensions', key)) | |
101 | |
102 def _defineLocalProperty(key, default = None): | |
103 """ | |
104 Creates a property corresponding with a repository-specific key in the con
fig file | |
105 """ | |
106 def getLocalProperty(self): | |
107 try: | 100 try: |
108 return self.config.get('extensions', self.repositoryName + '_' + key) | 101 return method('extensions', key) |
109 except NoOptionError, e: | 102 except NoOptionError: |
110 if default != None: | 103 if default is None: |
111 return default | 104 raise |
112 else: | 105 return default |
113 raise e | 106 |
114 return property(getLocalProperty) | 107 return property(getter) |
115 | 108 |
116 def _defineNightlyProperty(key): | 109 def _defineNightlyProperty(key): |
117 """ | 110 """ |
118 Creates a property corresponding with a key in the nightly config file | 111 Creates a property corresponding with a key in the nightly config file |
119 """ | 112 """ |
120 return property(lambda self: self.nightlyConfig.get(self.repositoryName, key
), | 113 return property(lambda self: self.nightlyConfig.get(self.repositoryName, key
), |
121 lambda self, value: self.nightlyConfig.set(self.repositoryNa
me, key, value)) | 114 lambda self, value: self.nightlyConfig.set(self.repositoryNa
me, key, value)) |
122 | 115 |
123 config = None | 116 config = None |
124 nightlyConfig = None | 117 nightlyConfig = None |
125 repositoryName = None | 118 repositoryName = None |
126 repository = None | 119 repository = None |
127 | 120 |
128 buildRepository = _defineGlobalProperty('buildRepository') | 121 buildRepository = _defineProperty('buildRepository') |
129 nightliesDirectory = _defineGlobalProperty('nightliesDirectory') | 122 nightliesDirectory = _defineProperty('nightliesDirectory') |
130 nightliesURL = _defineGlobalProperty('nightliesURL') | 123 nightliesURL = _defineProperty('nightliesURL') |
131 downloadsRepo = _defineGlobalProperty('downloadsRepo') | 124 downloadsRepo = _defineProperty('downloadsRepo') |
132 downloadsURL = _defineGlobalProperty('downloadsURL') | 125 downloadsURL = _defineProperty('downloadsURL') |
133 docsDirectory = _defineGlobalProperty('docsDirectory') | 126 docsDirectory = _defineProperty('docsDirectory') |
134 signtool = _defineGlobalProperty('signtool') | 127 signtool = _defineProperty('signtool') |
135 certname = _defineGlobalProperty('signtool_certname') | 128 certname = _defineProperty('signtool_certname') |
136 dbdir = _defineGlobalProperty('signtool_dbdir') | 129 dbdir = _defineProperty('signtool_dbdir') |
137 dbpass = _defineGlobalProperty('signtool_dbpass') | 130 dbpass = _defineProperty('signtool_dbpass') |
138 padDirectory = _defineGlobalProperty('padDirectory') | 131 padDirectory = _defineProperty('padDirectory') |
139 padURL = _defineGlobalProperty('padURL') | 132 padURL = _defineProperty('padURL') |
140 | 133 padTemplate = _defineProperty('padTemplate') |
141 keyFile = _defineLocalProperty('key', '') | 134 |
142 name = _defineLocalProperty('name') | 135 keyFile = _defineProperty('key', local=True, default='') |
143 galleryID = _defineLocalProperty('galleryID', '') | 136 name = _defineProperty('name', local=True) |
144 devbuildGalleryID = _defineLocalProperty('devbuildGalleryID', '') | 137 galleryID = _defineProperty('galleryID', local=True, default='') |
145 downloadPage = _defineLocalProperty('downloadPage', '') | 138 devbuildGalleryID = _defineProperty('devbuildGalleryID', local=True, default='
') |
146 experimental = _defineLocalProperty('experimental', '') | 139 downloadPage = _defineProperty('downloadPage', local=True, default='') |
147 clientID = _defineLocalProperty('clientID', '') | 140 experimental = _defineProperty('experimental', local=True, default='') |
148 clientSecret = _defineLocalProperty('clientSecret', '') | 141 clientID = _defineProperty('clientID', local=True, default='') |
149 refreshToken = _defineLocalProperty('refreshToken', '') | 142 clientSecret = _defineProperty('clientSecret', local=True, default='') |
150 padTemplate = _defineLocalProperty('padTemplate') | 143 refreshToken = _defineProperty('refreshToken', local=True, default='') |
| 144 pad = _defineProperty('pad', local=True, type='boolean', default=False) |
151 | 145 |
152 latestRevision = _defineNightlyProperty('latestRevision') | 146 latestRevision = _defineNightlyProperty('latestRevision') |
153 | 147 |
154 def __init__(self, config, nightlyConfig, repositoryName, repository): | 148 def __init__(self, config, nightlyConfig, repositoryName, repository): |
155 """ | 149 """ |
156 Creates a new Configuration instance that is bound to a particular | 150 Creates a new Configuration instance that is bound to a particular |
157 repository. | 151 repository. |
158 """ | 152 """ |
159 | 153 |
160 self.repositoryName = repositoryName | 154 self.repositoryName = repositoryName |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 except M2Crypto.X509.X509Error: | 249 except M2Crypto.X509.X509Error: |
256 raise Exception('No safari developer certificate found in chain') | 250 raise Exception('No safari developer certificate found in chain') |
257 | 251 |
258 subject = cert.get_subject() | 252 subject = cert.get_subject() |
259 for entry in subject.get_entries_by_nid(subject.nid['CN']): | 253 for entry in subject.get_entries_by_nid(subject.nid['CN']): |
260 m = re.match(r'Safari Developer: \((.*?)\)', entry.get_data().as_text()) | 254 m = re.match(r'Safari Developer: \((.*?)\)', entry.get_data().as_text()) |
261 if m: | 255 if m: |
262 return m.group(1) | 256 return m.group(1) |
263 finally: | 257 finally: |
264 bio.close() | 258 bio.close() |
LEFT | RIGHT |