Left: | ||
Right: |
OLD | NEW |
---|---|
1 # This Source Code Form is subject to the terms of the Mozilla Public | 1 # This Source Code Form is subject to the terms of the Mozilla Public |
2 # License, v. 2.0. If a copy of the MPL was not distributed with this | 2 # License, v. 2.0. If a copy of the MPL was not distributed with this |
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
4 | 4 |
5 import os | 5 import os |
6 import sys | 6 import sys |
7 import re | 7 import re |
8 import subprocess | 8 import subprocess |
9 import shutil | 9 import shutil |
10 from getopt import getopt, GetoptError | 10 from getopt import getopt, GetoptError |
11 from StringIO import StringIO | 11 from StringIO import StringIO |
12 from zipfile import ZipFile | 12 from zipfile import ZipFile |
13 | 13 |
14 knownTypes = ('gecko-webext', 'chrome', 'generic', 'edge') | 14 knownTypes = {'gecko-webext', 'chrome', 'generic', 'edge'} |
15 | 15 |
16 | 16 |
17 class Command(object): | 17 class Command(object): |
18 name = property(lambda self: self._name) | 18 name = property(lambda self: self._name) |
19 shortDescription = property( | 19 shortDescription = property( |
20 lambda self: self._shortDescription, | 20 lambda self: self._shortDescription, |
21 lambda self, value: self.__dict__.update({'_shortDescription': value}) | 21 lambda self, value: self.__dict__.update({'_shortDescription': value}) |
22 ) | 22 ) |
23 description = property( | 23 description = property( |
24 lambda self: self._description, | 24 lambda self: self._description, |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName, type), ('help', '-h', '--help')) as command: | 382 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName, type), ('help', '-h', '--help')) as command: |
383 command.shortDescription = 'Show this message' | 383 command.shortDescription = 'Show this message' |
384 | 384 |
385 with addCommand(runBuild, 'build') as command: | 385 with addCommand(runBuild, 'build') as command: |
386 command.shortDescription = 'Create a build' | 386 command.shortDescription = 'Create a build' |
387 command.description = 'Creates an extension build with given file name. If o utput_file is missing a default name will be chosen.' | 387 command.description = 'Creates an extension build with given file name. If o utput_file is missing a default name will be chosen.' |
388 command.params = '[options] [output_file]' | 388 command.params = '[options] [output_file]' |
389 command.addOption('Use given build number (if omitted the build number will be retrieved from Mercurial)', short='b', long='build', value='num') | 389 command.addOption('Use given build number (if omitted the build number will be retrieved from Mercurial)', short='b', long='build', value='num') |
390 command.addOption('File containing private key and certificates required to sign the package', short='k', long='key', value='file', types=('chrome',)) | 390 command.addOption('File containing private key and certificates required to sign the package', short='k', long='key', value='file', types=('chrome',)) |
391 command.addOption('Create a release build', short='r', long='release') | 391 command.addOption('Create a release build', short='r', long='release') |
392 command.supportedTypes = ('gecko-webext', 'chrome', 'edge') | 392 command.supportedTypes = ('gecko-webext', 'chrome', 'edge') |
Sebastian Noack
2017/10/10 18:34:28
Can we please turn these into sets as well?
tlucas
2017/10/11 13:21:15
Done.
| |
393 | 393 |
394 with addCommand(createDevEnv, 'devenv') as command: | 394 with addCommand(createDevEnv, 'devenv') as command: |
395 command.shortDescription = 'Set up a development environment' | 395 command.shortDescription = 'Set up a development environment' |
396 command.description = 'Will set up or update the devenv folder as an unpacke d extension folder for development.' | 396 command.description = 'Will set up or update the devenv folder as an unpacke d extension folder for development.' |
397 command.supportedTypes = ('gecko-webext', 'chrome') | 397 command.supportedTypes = ('gecko-webext', 'chrome') |
398 | 398 |
399 with addCommand(setupTranslations, 'setuptrans') as command: | 399 with addCommand(setupTranslations, 'setuptrans') as command: |
400 command.shortDescription = 'Sets up translation languages' | 400 command.shortDescription = 'Sets up translation languages' |
401 command.description = 'Sets up translation languages for the project on crow din.net.' | 401 command.description = 'Sets up translation languages for the project on crow din.net.' |
402 command.params = '[options] project-key' | 402 command.params = '[options] project-key' |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
462 elif len(types) > 1: | 462 elif len(types) > 1: |
463 print ''' | 463 print ''' |
464 Ambiguous repository type, please specify -t parameter explicitly, e.g. | 464 Ambiguous repository type, please specify -t parameter explicitly, e.g. |
465 %s -t %s build | 465 %s -t %s build |
466 ''' % (scriptName, types[0]) | 466 ''' % (scriptName, types[0]) |
467 return None | 467 return None |
468 else: | 468 else: |
469 print ''' | 469 print ''' |
470 No metadata file found in this repository, a metadata file like | 470 No metadata file found in this repository, a metadata file like |
471 metadata.%s is required. | 471 metadata.%s is required. |
472 ''' % knownTypes[0] | 472 ''' % knownTypes[0] |
kzar
2017/10/10 13:45:59
What about this, won't this fail?
Sebastian Noack
2017/10/10 18:34:28
Well spotted, it would fail. I suggest to just cha
tlucas
2017/10/11 13:21:15
Done.
| |
473 return None | 473 return None |
474 | 474 |
475 | 475 |
476 def processArgs(baseDir, args): | 476 def processArgs(baseDir, args): |
477 global commands | 477 global commands |
478 | 478 |
479 scriptName = os.path.basename(args[0]) | 479 scriptName = os.path.basename(args[0]) |
480 args = args[1:] | 480 args = args[1:] |
481 type = getType(baseDir, scriptName, args) | 481 type = getType(baseDir, scriptName, args) |
482 if type == None: | 482 if type == None: |
(...skipping 20 matching lines...) Expand all Loading... | |
503 if option in ('-h', '--help'): | 503 if option in ('-h', '--help'): |
504 usage(scriptName, type, command) | 504 usage(scriptName, type, command) |
505 sys.exit() | 505 sys.exit() |
506 commands[command](baseDir, scriptName, opts, args, type) | 506 commands[command](baseDir, scriptName, opts, args, type) |
507 else: | 507 else: |
508 print 'Command %s is not supported for this application type' % comm and | 508 print 'Command %s is not supported for this application type' % comm and |
509 usage(scriptName, type) | 509 usage(scriptName, type) |
510 else: | 510 else: |
511 print 'Command %s is unrecognized' % command | 511 print 'Command %s is unrecognized' % command |
512 usage(scriptName, type) | 512 usage(scriptName, type) |
OLD | NEW |