 Issue 29587910:
  Issue 104 - added checktranslations function
    
  
    Issue 29587910:
  Issue 104 - added checktranslations function 
  | Left: | ||
| Right: | 
| LEFT | RIGHT | 
|---|---|
| 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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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): | 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 | |
| 386 import buildtools.localeTools as localetools | 391 import buildtools.localeTools as localetools | 
| 387 localetools.check_translations(baseDir) | 392 localetools.check_translations(localeConfig) | 
| 388 | 393 | 
| 389 | 394 | 
| 390 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: | 
| 391 command.shortDescription = 'Show this message' | 396 command.shortDescription = 'Show this message' | 
| 392 | 397 | 
| 393 with addCommand(runBuild, 'build') as command: | 398 with addCommand(runBuild, 'build') as command: | 
| 394 command.shortDescription = 'Create a build' | 399 command.shortDescription = 'Create a build' | 
| 395 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.' | 
| 396 command.params = '[options] [output_file]' | 401 command.params = '[options] [output_file]' | 
| 397 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') | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 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') | 
| 440 command.params = '[options] <version>' | 445 command.params = '[options] <version>' | 
| 441 command.supportedTypes = {'chrome', 'edge'} | 446 command.supportedTypes = {'chrome', 'edge'} | 
| 442 | 447 | 
| 443 with addCommand(updatePSL, 'updatepsl') as command: | 448 with addCommand(updatePSL, 'updatepsl') as command: | 
| 444 command.shortDescription = 'Updates Public Suffix List' | 449 command.shortDescription = 'Updates Public Suffix List' | 
| 445 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.' | 
| 446 command.supportedTypes = {'chrome'} | 451 command.supportedTypes = {'chrome'} | 
| 447 | 452 | 
| 448 with addCommand(check_translations, 'checktranslations') as command: | 453 with addCommand(check_translations, 'checktranslations') as command: | 
| 449 command.shortDescription = 'Checks translation files for overlong, missing a nd structure' | 454 command.shortDescription = 'Perform translation checks.' | 
| 
tlucas
2017/10/25 15:09:23
nit: this line exceeds 79 characters
nit: "Checks
 
erick
2017/10/29 03:45:54
Acknowledged.
 | |
| 450 command.description = 'JSON files translations will be checked by this funct ionality' | 455 command.description = 'Checks translations files for structure and for overl ong translations.' | 
| 
tlucas
2017/10/25 15:09:23
nit: this line exceeds 79 characters
nit: descript
 
erick
2017/10/29 03:45:54
Acknowledged.
 | |
| 451 | 456 | 
| 452 | 457 | 
| 453 def getType(baseDir, scriptName, args): | 458 def getType(baseDir, scriptName, args): | 
| 454 # 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) | 
| 455 if len(args) >= 2 and args[0] == '-t': | 460 if len(args) >= 2 and args[0] == '-t': | 
| 456 type = args[1] | 461 type = args[1] | 
| 457 del args[1] | 462 del args[1] | 
| 458 del args[0] | 463 del args[0] | 
| 459 if type not in knownTypes: | 464 if type not in knownTypes: | 
| 460 print ''' | 465 print ''' | 
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 if option in {'-h', '--help'}: | 520 if option in {'-h', '--help'}: | 
| 516 usage(scriptName, type, command) | 521 usage(scriptName, type, command) | 
| 517 sys.exit() | 522 sys.exit() | 
| 518 commands[command](baseDir, scriptName, opts, args, type) | 523 commands[command](baseDir, scriptName, opts, args, type) | 
| 519 else: | 524 else: | 
| 520 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 | 
| 521 usage(scriptName, type) | 526 usage(scriptName, type) | 
| 522 else: | 527 else: | 
| 523 print 'Command %s is unrecognized' % command | 528 print 'Command %s is unrecognized' % command | 
| 524 usage(scriptName, type) | 529 usage(scriptName, type) | 
| LEFT | RIGHT |