Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # coding: utf-8 | 1 # coding: utf-8 |
2 | 2 |
3 # This Source Code Form is subject to the terms of the Mozilla Public | 3 # This Source Code Form is subject to the terms of the Mozilla Public |
4 # License, v. 2.0. If a copy of the MPL was not distributed with this | 4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
6 | 6 |
7 import sys | 7 import sys |
8 import os | 8 import os |
9 import re | 9 import re |
10 import json | 10 import json |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 # ... = icon.png popup.html | 86 # ... = icon.png popup.html |
87 icon, popup = icons | 87 icon, popup = icons |
88 else: | 88 else: |
89 # ... = icon-19.png icon-38.png popup.html | 89 # ... = icon-19.png icon-38.png popup.html |
90 popup = icons.pop() | 90 popup = icons.pop() |
91 icon = makeIcons(files, icons) | 91 icon = makeIcons(files, icons) |
92 | 92 |
93 templateData[opt] = {'icon': icon, 'popup': popup} | 93 templateData[opt] = {'icon': icon, 'popup': popup} |
94 | 94 |
95 if metadata.has_option('general', 'icons'): | 95 if metadata.has_option('general', 'icons'): |
96 templateData['icons'] = makeIcons(files, metadata.get('general', 'icons').sp lit()) | 96 templateData['icons'] = makeIcons(files, |
97 metadata.get('general', 'icons').split()) | |
97 | 98 |
98 if metadata.has_option('general', 'permissions'): | 99 if metadata.has_option('general', 'permissions'): |
99 templateData['permissions'] = re.split(r'\s+', metadata.get('general', 'perm issions')) | 100 templateData['permissions'] = metadata.get('general', 'permissions').split() |
100 if params['experimentalAPI']: | 101 if params['experimentalAPI']: |
101 templateData['permissions'].append('experimental') | 102 templateData['permissions'].append('experimental') |
102 | 103 |
103 if metadata.has_option('general', 'optionalPermissions'): | 104 if metadata.has_option('general', 'optionalPermissions'): |
104 templateData['optionalPermissions'] = re.split( | 105 templateData['optionalPermissions'] = metadata.get( |
Sebastian Noack
2016/01/14 16:26:11
Note that re.split(r'\s+', s) is equivalent to s.s
kzar
2016/01/14 16:39:07
I know, just staying consistent with the surroundi
Sebastian Noack
2016/01/14 16:41:54
Feel free to change it in the other places as well
| |
105 r'\s+', metadata.get('general', 'optionalPermissions') | 106 'general', 'optionalPermissions').split() |
106 ) | |
107 | 107 |
108 if metadata.has_option('general', 'backgroundScripts'): | 108 if metadata.has_option('general', 'backgroundScripts'): |
109 templateData['backgroundScripts'] = re.split(r'\s+', metadata.get('general', 'backgroundScripts')) | 109 templateData['backgroundScripts'] = metadata.get( |
110 'general', 'backgroundScripts').split() | |
110 if params['devenv']: | 111 if params['devenv']: |
111 templateData['backgroundScripts'].append('devenvPoller__.js') | 112 templateData['backgroundScripts'].append('devenvPoller__.js') |
112 | 113 |
113 if metadata.has_option('general', 'webAccessible') and metadata.get('general', 'webAccessible') != '': | 114 if metadata.has_option('general', 'webAccessible') and metadata.get('general', 'webAccessible') != '': |
114 templateData['webAccessible'] = re.split(r'\s+', metadata.get('general', 'we bAccessible')) | 115 templateData['webAccessible'] = metadata.get('general', |
116 'webAccessible').split() | |
115 | 117 |
116 if metadata.has_section('contentScripts'): | 118 if metadata.has_section('contentScripts'): |
117 contentScripts = [] | 119 contentScripts = [] |
118 for run_at, scripts in metadata.items('contentScripts'): | 120 for run_at, scripts in metadata.items('contentScripts'): |
119 if scripts == '': | 121 if scripts == '': |
120 continue | 122 continue |
121 contentScripts.append({ | 123 contentScripts.append({ |
122 'matches': ['http://*/*', 'https://*/*'], | 124 'matches': ['http://*/*', 'https://*/*'], |
123 'js': re.split(r'\s+', scripts), | 125 'js': scripts.split(), |
124 'run_at': run_at, | 126 'run_at': run_at, |
125 'all_frames': True, | 127 'all_frames': True, |
126 'match_about_blank': True, | 128 'match_about_blank': True, |
127 }) | 129 }) |
128 templateData['contentScripts'] = contentScripts | 130 templateData['contentScripts'] = contentScripts |
129 | 131 |
130 manifest = template.render(templateData) | 132 manifest = template.render(templateData) |
131 | 133 |
132 # Normalize JSON structure | 134 # Normalize JSON structure |
133 licenseComment = re.compile(r'/\*.*?\*/', re.S) | 135 licenseComment = re.compile(r'/\*.*?\*/', re.S) |
(...skipping 12 matching lines...) Expand all Loading... | |
146 from jshydra.abp_rewrite import doRewrite | 148 from jshydra.abp_rewrite import doRewrite |
147 | 149 |
148 for item in params['metadata'].items('convert_js'): | 150 for item in params['metadata'].items('convert_js'): |
149 file, sources = item | 151 file, sources = item |
150 baseDir = os.path.dirname(item.source) | 152 baseDir = os.path.dirname(item.source) |
151 | 153 |
152 # Make sure the file is inside an included directory | 154 # Make sure the file is inside an included directory |
153 if '/' in file and not files.isIncluded(file): | 155 if '/' in file and not files.isIncluded(file): |
154 continue | 156 continue |
155 | 157 |
156 sourceFiles = re.split(r'\s+', sources) | 158 sourceFiles = sources.split() |
157 args = [] | 159 args = [] |
158 try: | 160 try: |
159 argsStart = sourceFiles.index('--arg') | 161 argsStart = sourceFiles.index('--arg') |
160 args = sourceFiles[argsStart + 1:] | 162 args = sourceFiles[argsStart + 1:] |
161 sourceFiles = sourceFiles[0:argsStart] | 163 sourceFiles = sourceFiles[0:argsStart] |
162 except ValueError: | 164 except ValueError: |
163 pass | 165 pass |
164 | 166 |
165 # Source files of the conversion shouldn't be part of the build | 167 # Source files of the conversion shouldn't be part of the build |
166 for sourceFile in sourceFiles: | 168 for sourceFile in sourceFiles: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 sourceData = localeTools.readFile(sourceFile) | 222 sourceData = localeTools.readFile(sourceFile) |
221 | 223 |
222 # Resolve wildcard imports | 224 # Resolve wildcard imports |
223 if keys == '*' or keys == '=*': | 225 if keys == '*' or keys == '=*': |
224 importList = sourceData.keys() | 226 importList = sourceData.keys() |
225 importList = filter(lambda k: not k.startswith('_'), importList) | 227 importList = filter(lambda k: not k.startswith('_'), importList) |
226 if keys == '=*': | 228 if keys == '=*': |
227 importList = map(lambda k: '=' + k, importList) | 229 importList = map(lambda k: '=' + k, importList) |
228 keys = ' '.join(importList) | 230 keys = ' '.join(importList) |
229 | 231 |
230 for stringID in re.split(r'\s+', keys): | 232 for stringID in keys.split(): |
231 noMangling = False | 233 noMangling = False |
232 if stringID.startswith('='): | 234 if stringID.startswith('='): |
233 stringID = stringID[1:] | 235 stringID = stringID[1:] |
234 noMangling = True | 236 noMangling = True |
235 | 237 |
236 if stringID in sourceData: | 238 if stringID in sourceData: |
237 if noMangling: | 239 if noMangling: |
238 key = re.sub(r'\W', '_', stringID) | 240 key = re.sub(r'\W', '_', stringID) |
239 else: | 241 else: |
240 key = re.sub(r'\..*', '', parts[-1]) + '_' + re.sub(r'\W', '_', st ringID) | 242 key = re.sub(r'\..*', '', parts[-1]) + '_' + re.sub(r'\W', '_', st ringID) |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 if type == 'chrome': | 360 if type == 'chrome': |
359 fixTranslationsForCWS(files) | 361 fixTranslationsForCWS(files) |
360 | 362 |
361 if devenv: | 363 if devenv: |
362 import buildtools | 364 import buildtools |
363 import random | 365 import random |
364 files.read(os.path.join(buildtools.__path__[0], 'chromeDevenvPoller__.js'), relpath='devenvPoller__.js') | 366 files.read(os.path.join(buildtools.__path__[0], 'chromeDevenvPoller__.js'), relpath='devenvPoller__.js') |
365 files['devenvVersion__'] = str(random.random()) | 367 files['devenvVersion__'] = str(random.random()) |
366 | 368 |
367 if (metadata.has_option('general', 'backgroundScripts') and | 369 if (metadata.has_option('general', 'backgroundScripts') and |
368 'lib/info.js' in re.split(r'\s+', metadata.get('general', 'backgroundScrip ts')) and | 370 'lib/info.js' in metadata.get('general', 'backgroundScripts').split() and |
369 'lib/info.js' not in files): | 371 'lib/info.js' not in files): |
370 files['lib/info.js'] = createInfoModule(params) | 372 files['lib/info.js'] = createInfoModule(params) |
371 | 373 |
372 if metadata.has_option('general', 'testScripts'): | 374 if metadata.has_option('general', 'testScripts'): |
373 files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmpl', | 375 files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmpl', |
374 ('general', 'testScripts')) | 376 ('general', 'testScripts')) |
375 | 377 |
376 zipdata = files.zipToString() | 378 zipdata = files.zipToString() |
377 signature = None | 379 signature = None |
378 pubkey = None | 380 pubkey = None |
379 if keyFile != None: | 381 if keyFile != None: |
380 signature = signBinary(zipdata, keyFile) | 382 signature = signBinary(zipdata, keyFile) |
381 pubkey = getPublicKey(keyFile) | 383 pubkey = getPublicKey(keyFile) |
382 writePackage(outFile, pubkey, signature, zipdata) | 384 writePackage(outFile, pubkey, signature, zipdata) |
LEFT | RIGHT |