Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # coding: utf-8 | 1 # coding: utf-8 |
2 | 2 |
3 # This Source Code is subject to the terms of the Mozilla Public License | 3 # This Source Code is subject to the terms of the Mozilla Public License |
4 # version 2.0 (the "License"). You can obtain a copy of the License at | 4 # version 2.0 (the "License"). You can obtain a copy of the License at |
5 # http://mozilla.org/MPL/2.0/. | 5 # http://mozilla.org/MPL/2.0/. |
6 | 6 |
7 import os, sys, re, subprocess, buildtools | 7 import os, sys, re, subprocess, buildtools |
8 from getopt import getopt, GetoptError | 8 from getopt import getopt, GetoptError |
9 | 9 |
10 class Command(object): | 10 class Command(object): |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 if type == 'gecko': | 182 if type == 'gecko': |
183 import buildtools.packagerGecko as packager | 183 import buildtools.packagerGecko as packager |
184 packager.createBuild(baseDir, outFile=outFile, locales=locales, buildNum=bui ldNum, | 184 packager.createBuild(baseDir, outFile=outFile, locales=locales, buildNum=bui ldNum, |
185 releaseBuild=releaseBuild, keyFile=keyFile, | 185 releaseBuild=releaseBuild, keyFile=keyFile, |
186 limitMetadata=limitMetadata, multicompartment=multicomp artment) | 186 limitMetadata=limitMetadata, multicompartment=multicomp artment) |
187 elif type == 'chrome': | 187 elif type == 'chrome': |
188 import buildtools.packagerChrome as packager | 188 import buildtools.packagerChrome as packager |
189 packager.createBuild(baseDir, outFile=outFile, buildNum=buildNum, | 189 packager.createBuild(baseDir, outFile=outFile, buildNum=buildNum, |
190 releaseBuild=releaseBuild, keyFile=keyFile, | 190 releaseBuild=releaseBuild, keyFile=keyFile, |
191 experimentalAPI=experimentalAPI) | 191 experimentalAPI=experimentalAPI) |
192 elif type == 'kmeleon': | 192 elif type == 'kmeleon': |
Felix Dahlke
2013/01/10 16:36:20
Shouldn't we get rid of this while we're at it?
Wladimir Palant
2013/01/16 14:20:15
This was done in a separate batch of changes.
| |
193 import buildtools.packagerKMeleon as packager | 193 import buildtools.packagerKMeleon as packager |
194 packager.createBuild(baseDir, outFile=outFile, locales=locales, | 194 packager.createBuild(baseDir, outFile=outFile, locales=locales, |
195 buildNum=buildNum, releaseBuild=releaseBuild) | 195 buildNum=buildNum, releaseBuild=releaseBuild) |
196 | 196 |
197 def runAutoInstall(baseDir, scriptName, opts, args, type): | 197 def runAutoInstall(baseDir, scriptName, opts, args, type): |
198 if len(args) == 0: | 198 if len(args) == 0: |
199 print 'Port of the Extension Auto-Installer needs to be specified' | 199 print 'Port of the Extension Auto-Installer needs to be specified' |
200 usage(scriptName, type, 'autoinstall') | 200 usage(scriptName, type, 'autoinstall') |
201 return | 201 return |
202 | 202 |
(...skipping 17 matching lines...) Expand all Loading... | |
220 usage(scriptName, type, 'setuptrans') | 220 usage(scriptName, type, 'setuptrans') |
221 return | 221 return |
222 | 222 |
223 key = args[0] | 223 key = args[0] |
224 | 224 |
225 if type == 'chrome': | 225 if type == 'chrome': |
226 import buildtools.packagerChrome as packager | 226 import buildtools.packagerChrome as packager |
227 locales = os.listdir(os.path.join(baseDir, '_locales')) | 227 locales = os.listdir(os.path.join(baseDir, '_locales')) |
228 locales = map(lambda locale: locale.replace('_', '-'), locales) | 228 locales = map(lambda locale: locale.replace('_', '-'), locales) |
229 basename = packager.readMetadata(baseDir).get('general', 'baseName') | 229 basename = packager.readMetadata(baseDir).get('general', 'baseName') |
230 else: | 230 else: |
Felix Dahlke
2013/01/10 16:36:20
Shouldn't we check for the type here as well and h
Wladimir Palant
2013/01/16 14:20:15
Yes, that command is only available for the chrome
| |
231 import buildtools.packagerGecko as packager | 231 import buildtools.packagerGecko as packager |
232 locales = packager.getLocales(baseDir, True) | 232 locales = packager.getLocales(baseDir, True) |
233 basename = packager.readMetadata(baseDir).get('general', 'baseName') | 233 basename = packager.readMetadata(baseDir).get('general', 'baseName') |
234 | 234 |
235 import buildtools.localeTools as localeTools | 235 import buildtools.localeTools as localeTools |
236 localeTools.setupTranslations(type, locales, basename, key) | 236 localeTools.setupTranslations(type, locales, basename, key) |
237 | 237 |
238 | 238 |
239 def updateTranslationMaster(baseDir, scriptName, opts, args, type): | 239 def updateTranslationMaster(baseDir, scriptName, opts, args, type): |
240 if len(args) < 1: | 240 if len(args) < 1: |
241 print 'Project key is required to update translation master files.' | 241 print 'Project key is required to update translation master files.' |
242 usage(scriptName, type, 'translate') | 242 usage(scriptName, type, 'translate') |
243 return | 243 return |
244 | 244 |
245 key = args[0] | 245 key = args[0] |
246 | 246 |
247 if type == 'chrome': | 247 if type == 'chrome': |
248 import buildtools.packagerChrome as packager | 248 import buildtools.packagerChrome as packager |
249 defaultLocaleDir = os.path.join(baseDir, '_locales', packager.defaultLocale) | 249 defaultLocaleDir = os.path.join(baseDir, '_locales', packager.defaultLocale) |
250 metadata = packager.readMetadata(baseDir) | 250 metadata = packager.readMetadata(baseDir) |
251 basename = metadata.get('general', 'baseName') | 251 basename = metadata.get('general', 'baseName') |
252 else: | 252 else: |
Felix Dahlke
2013/01/10 16:36:20
Same as above.
| |
253 import buildtools.packagerGecko as packager | 253 import buildtools.packagerGecko as packager |
254 defaultLocaleDir = os.path.join(packager.getLocalesDir(baseDir), packager.de faultLocale) | 254 defaultLocaleDir = os.path.join(packager.getLocalesDir(baseDir), packager.de faultLocale) |
255 metadata = packager.readMetadata(baseDir) | 255 metadata = packager.readMetadata(baseDir) |
256 basename = metadata.get('general', 'baseName') | 256 basename = metadata.get('general', 'baseName') |
257 | 257 |
258 import buildtools.localeTools as localeTools | 258 import buildtools.localeTools as localeTools |
259 localeTools.updateTranslationMaster(type, metadata, defaultLocaleDir, basename , key) | 259 localeTools.updateTranslationMaster(type, metadata, defaultLocaleDir, basename , key) |
260 | 260 |
261 | 261 |
262 def uploadTranslations(baseDir, scriptName, opts, args, type): | 262 def uploadTranslations(baseDir, scriptName, opts, args, type): |
263 if len(args) < 1: | 263 if len(args) < 1: |
264 print 'Project key is required to upload existing translations.' | 264 print 'Project key is required to upload existing translations.' |
265 usage(scriptName, type, 'uploadtrans') | 265 usage(scriptName, type, 'uploadtrans') |
266 return | 266 return |
267 | 267 |
268 key = args[0] | 268 key = args[0] |
269 | 269 |
270 if type == 'chrome': | 270 if type == 'chrome': |
271 import buildtools.packagerChrome as packager | 271 import buildtools.packagerChrome as packager |
272 localesDir = os.path.join(baseDir, '_locales') | 272 localesDir = os.path.join(baseDir, '_locales') |
273 locales = os.listdir(localesDir) | 273 locales = os.listdir(localesDir) |
274 locales = map(lambda locale: (locale.replace('_', '-'), os.path.join(locales Dir, locale)), locales) | 274 locales = map(lambda locale: (locale.replace('_', '-'), os.path.join(locales Dir, locale)), locales) |
275 metadata = packager.readMetadata(baseDir) | 275 metadata = packager.readMetadata(baseDir) |
276 basename = metadata.get('general', 'baseName') | 276 basename = metadata.get('general', 'baseName') |
277 else: | 277 else: |
Felix Dahlke
2013/01/10 16:36:20
Same as above.
| |
278 import buildtools.packagerGecko as packager | 278 import buildtools.packagerGecko as packager |
279 localesDir = packager.getLocalesDir(baseDir) | 279 localesDir = packager.getLocalesDir(baseDir) |
280 locales = packager.getLocales(baseDir, True) | 280 locales = packager.getLocales(baseDir, True) |
281 locales = map(lambda locale: (locale, os.path.join(localesDir, locale)), loc ales) | 281 locales = map(lambda locale: (locale, os.path.join(localesDir, locale)), loc ales) |
282 metadata = packager.readMetadata(baseDir) | 282 metadata = packager.readMetadata(baseDir) |
283 basename = metadata.get('general', 'baseName') | 283 basename = metadata.get('general', 'baseName') |
284 | 284 |
285 import buildtools.localeTools as localeTools | 285 import buildtools.localeTools as localeTools |
286 for locale, localeDir in locales: | 286 for locale, localeDir in locales: |
287 if locale != packager.defaultLocale: | 287 if locale != packager.defaultLocale: |
288 localeTools.uploadTranslations(type, metadata, localeDir, locale, basename , key) | 288 localeTools.uploadTranslations(type, metadata, localeDir, locale, basename , key) |
289 | 289 |
290 | 290 |
291 def getTranslations(baseDir, scriptName, opts, args, type): | 291 def getTranslations(baseDir, scriptName, opts, args, type): |
292 if len(args) < 1: | 292 if len(args) < 1: |
293 print 'Project key is required to update translation master files.' | 293 print 'Project key is required to update translation master files.' |
294 usage(scriptName, type, 'translate') | 294 usage(scriptName, type, 'translate') |
295 return | 295 return |
296 | 296 |
297 key = args[0] | 297 key = args[0] |
298 import buildtools.packagerGecko as packager | 298 if type == 'chrome': |
Felix Dahlke
2013/01/10 16:36:20
Same as above.
| |
299 localesDir = packager.getLocalesDir(baseDir) | 299 import buildtools.packagerChrome as packager |
300 localesDir = os.path.join(baseDir, '_locales') | |
301 else: | |
302 import buildtools.packagerGecko as packager | |
303 localesDir = packager.getLocalesDir(baseDir) | |
304 | |
305 import buildtools.localeTools as localeTools | |
300 basename = packager.readMetadata(baseDir).get('general', 'baseName') | 306 basename = packager.readMetadata(baseDir).get('general', 'baseName') |
301 | 307 localeTools.getTranslations(type, localesDir, packager.defaultLocale.replace(' _', '-'), basename, key) |
302 import buildtools.localeTools as localeTools | |
303 localeTools.getTranslations(localesDir, packager.defaultLocale, basename, key) | |
304 | 308 |
305 | 309 |
306 def showDescriptions(baseDir, scriptName, opts, args, type): | 310 def showDescriptions(baseDir, scriptName, opts, args, type): |
307 locales = None | 311 locales = None |
308 for option, value in opts: | 312 for option, value in opts: |
309 if option in ('-l', '--locales'): | 313 if option in ('-l', '--locales'): |
310 locales = value.split(',') | 314 locales = value.split(',') |
311 | 315 |
312 import buildtools.packagerGecko as packager | 316 import buildtools.packagerGecko as packager |
313 if locales == None: | 317 if locales == None: |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
444 with addCommand(uploadTranslations, 'uploadtrans') as command: | 448 with addCommand(uploadTranslations, 'uploadtrans') as command: |
445 command.shortDescription = 'Uploads existing translations' | 449 command.shortDescription = 'Uploads existing translations' |
446 command.description = 'Uploads already existing translations to the project on crowdin.net.' | 450 command.description = 'Uploads already existing translations to the project on crowdin.net.' |
447 command.params = '[options] project-key' | 451 command.params = '[options] project-key' |
448 command.supportedTypes = ('gecko', 'chrome') | 452 command.supportedTypes = ('gecko', 'chrome') |
449 | 453 |
450 with addCommand(getTranslations, 'gettranslations') as command: | 454 with addCommand(getTranslations, 'gettranslations') as command: |
451 command.shortDescription = 'Downloads translation updates' | 455 command.shortDescription = 'Downloads translation updates' |
452 command.description = 'Downloads updated translations from crowdin.net.' | 456 command.description = 'Downloads updated translations from crowdin.net.' |
453 command.params = '[options] project-key' | 457 command.params = '[options] project-key' |
454 command.supportedTypes = ('gecko') | 458 command.supportedTypes = ('gecko', 'chrome') |
455 | 459 |
456 with addCommand(showDescriptions, 'showdesc') as command: | 460 with addCommand(showDescriptions, 'showdesc') as command: |
457 command.shortDescription = 'Print description strings for all locales' | 461 command.shortDescription = 'Print description strings for all locales' |
458 command.description = 'Display description strings for all locales as specifie d in the corresponding meta.properties files.' | 462 command.description = 'Display description strings for all locales as specifie d in the corresponding meta.properties files.' |
459 command.addOption('Only include the given locales', short='l', long='locales', value='l1,l2,l3') | 463 command.addOption('Only include the given locales', short='l', long='locales', value='l1,l2,l3') |
460 command.params = '[options]' | 464 command.params = '[options]' |
461 command.supportedTypes = ('gecko') | 465 command.supportedTypes = ('gecko') |
462 | 466 |
463 with addCommand(generateDocs, 'docs') as command: | 467 with addCommand(generateDocs, 'docs') as command: |
464 command.shortDescription = 'Generate documentation' | 468 command.shortDescription = 'Generate documentation' |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
515 if option in ('-h', '--help'): | 519 if option in ('-h', '--help'): |
516 usage(scriptName, type, command) | 520 usage(scriptName, type, command) |
517 sys.exit() | 521 sys.exit() |
518 commands[command](baseDir, scriptName, opts, args, type) | 522 commands[command](baseDir, scriptName, opts, args, type) |
519 else: | 523 else: |
520 print 'Command %s is not supported for this application type' % command | 524 print 'Command %s is not supported for this application type' % command |
521 usage(scriptName, type) | 525 usage(scriptName, type) |
522 else: | 526 else: |
523 print 'Command %s is unrecognized' % command | 527 print 'Command %s is unrecognized' % command |
524 usage(scriptName, type) | 528 usage(scriptName, type) |
LEFT | RIGHT |