Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: build.py

Issue 29587910: Issue 104 - added checktranslations function
Patch Set: Proposed changes Created Nov. 20, 2017, 11:39 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | localeTools.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 375
376 import buildtools.releaseAutomation as releaseAutomation 376 import buildtools.releaseAutomation as releaseAutomation
377 releaseAutomation.run(baseDir, type, version, keyFile, downloadsRepo) 377 releaseAutomation.run(baseDir, type, version, keyFile, downloadsRepo)
378 378
379 379
380 def updatePSL(baseDir, scriptName, opts, args, type): 380 def updatePSL(baseDir, scriptName, opts, args, type):
381 import buildtools.publicSuffixListUpdater as publicSuffixListUpdater 381 import buildtools.publicSuffixListUpdater as publicSuffixListUpdater
382 publicSuffixListUpdater.updatePSL(baseDir) 382 publicSuffixListUpdater.updatePSL(baseDir)
383 383
384 384
385 def check_translations(baseDir, scriptName, opts, args, type):
386 from buildtools.packager import readMetadata
387 metadata = readMetadata(baseDir, type)
388
389 localeConfig = readLocaleConfig(baseDir, type, metadata)
390
391 import buildtools.localeTools as localetools
392 localetools.check_translations(localeConfig)
393
394
385 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName, type), ('help', '-h', '--help')) as command: 395 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName, type), ('help', '-h', '--help')) as command:
386 command.shortDescription = 'Show this message' 396 command.shortDescription = 'Show this message'
387 397
388 with addCommand(runBuild, 'build') as command: 398 with addCommand(runBuild, 'build') as command:
389 command.shortDescription = 'Create a build' 399 command.shortDescription = 'Create a build'
390 command.description = 'Creates an extension build with given file name. If o utput_file is missing a default name will be chosen.' 400 command.description = 'Creates an extension build with given file name. If o utput_file is missing a default name will be chosen.'
391 command.params = '[options] [output_file]' 401 command.params = '[options] [output_file]'
392 command.addOption('Use given build number (if omitted the build number will be retrieved from Mercurial)', short='b', long='build', value='num') 402 command.addOption('Use given build number (if omitted the build number will be retrieved from Mercurial)', short='b', long='build', value='num')
393 command.addOption('File containing private key and certificates required to sign the package', short='k', long='key', value='file', types={'chrome'}) 403 command.addOption('File containing private key and certificates required to sign the package', short='k', long='key', value='file', types={'chrome'})
394 command.addOption('Create a release build', short='r', long='release') 404 command.addOption('Create a release build', short='r', long='release')
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 command.addOption('File containing private key and certificates required to sign the release.', short='k', long='key', value='file', types={'chrome', 'edge' }) 443 command.addOption('File containing private key and certificates required to sign the release.', short='k', long='key', value='file', types={'chrome', 'edge' })
434 command.addOption('Directory containing downloads repository (if omitted ../ downloads is assumed)', short='d', long='downloads', value='dir') 444 command.addOption('Directory containing downloads repository (if omitted ../ downloads is assumed)', short='d', long='downloads', value='dir')
435 command.params = '[options] <version>' 445 command.params = '[options] <version>'
436 command.supportedTypes = {'chrome', 'edge'} 446 command.supportedTypes = {'chrome', 'edge'}
437 447
438 with addCommand(updatePSL, 'updatepsl') as command: 448 with addCommand(updatePSL, 'updatepsl') as command:
439 command.shortDescription = 'Updates Public Suffix List' 449 command.shortDescription = 'Updates Public Suffix List'
440 command.description = 'Downloads Public Suffix List (see http://publicsuffix .org/) and generates lib/publicSuffixList.js from it.' 450 command.description = 'Downloads Public Suffix List (see http://publicsuffix .org/) and generates lib/publicSuffixList.js from it.'
441 command.supportedTypes = {'chrome'} 451 command.supportedTypes = {'chrome'}
442 452
453 with addCommand(check_translations, 'checktranslations') as command:
454 command.shortDescription = 'Perform translation checks.'
455 command.description = 'Checks translations files for structure and for overl ong translations.'
456
443 457
444 def getType(baseDir, scriptName, args): 458 def getType(baseDir, scriptName, args):
445 # Look for an explicit type parameter (has to be the first parameter) 459 # Look for an explicit type parameter (has to be the first parameter)
446 if len(args) >= 2 and args[0] == '-t': 460 if len(args) >= 2 and args[0] == '-t':
447 type = args[1] 461 type = args[1]
448 del args[1] 462 del args[1]
449 del args[0] 463 del args[0]
450 if type not in knownTypes: 464 if type not in knownTypes:
451 print ''' 465 print '''
452 Unknown type %s specified, supported types are: %s 466 Unknown type %s specified, supported types are: %s
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 if option in {'-h', '--help'}: 520 if option in {'-h', '--help'}:
507 usage(scriptName, type, command) 521 usage(scriptName, type, command)
508 sys.exit() 522 sys.exit()
509 commands[command](baseDir, scriptName, opts, args, type) 523 commands[command](baseDir, scriptName, opts, args, type)
510 else: 524 else:
511 print 'Command %s is not supported for this application type' % comm and 525 print 'Command %s is not supported for this application type' % comm and
512 usage(scriptName, type) 526 usage(scriptName, type)
513 else: 527 else:
514 print 'Command %s is unrecognized' % command 528 print 'Command %s is unrecognized' % command
515 usage(scriptName, type) 529 usage(scriptName, type)
OLDNEW
« no previous file with comments | « no previous file | localeTools.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld