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

Delta Between Two Patch Sets: build.py

Issue 29561557: Issue 5763 - Target languages supported by Firefox (Closed)
Left Patch Set: Adressed Vasily's comments Created Oct. 2, 2017, 10:57 p.m.
Right Patch Set: Fixed undefined variable, put URLS in globals, removed redundand flake8 ignores Created Oct. 5, 2017, 8:54 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | localeTools.py » ('j') | packagerChrome.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 import buildtools 10 import buildtools
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 zip_file.extractall(devenv_dir) 245 zip_file.extractall(devenv_dir)
246 246
247 247
248 def readLocaleConfig(baseDir, type, metadata): 248 def readLocaleConfig(baseDir, type, metadata):
249 if type == 'gecko': 249 if type == 'gecko':
250 import buildtools.packagerGecko as packager 250 import buildtools.packagerGecko as packager
251 localeDir = packager.getLocalesDir(baseDir) 251 localeDir = packager.getLocalesDir(baseDir)
252 localeConfig = { 252 localeConfig = {
253 'name_format': 'BCP-47', 253 'name_format': 'BCP-47',
254 'file_format': 'gecko-dtd', 254 'file_format': 'gecko-dtd',
255 'target_platforms': {'gecko'},
256 'default_locale': packager.defaultLocale 255 'default_locale': packager.defaultLocale
257 } 256 }
258 elif type in {'chrome', 'gecko-webext'}: 257 elif type in {'chrome', 'gecko-webext'}:
259 import buildtools.packagerChrome as packager 258 import buildtools.packagerChrome as packager
260 localeDir = os.path.join(baseDir, '_locales') 259 localeDir = os.path.join(baseDir, '_locales')
261 localeConfig = { 260 localeConfig = {
262 'name_format': 'ISO-15897', 261 'name_format': 'ISO-15897',
263 'file_format': 'chrome-json', 262 'file_format': 'chrome-json',
264 'target_platforms': {'chrome'},
265 'default_locale': packager.defaultLocale, 263 'default_locale': packager.defaultLocale,
266 } 264 }
267 else: 265 else:
268 localeDir = os.path.join( 266 localeDir = os.path.join(
269 baseDir, *metadata.get('locales', 'base_path').split('/') 267 baseDir, *metadata.get('locales', 'base_path').split('/')
270 ) 268 )
271 localeConfig = { 269 localeConfig = {
272 'name_format': metadata.get('locales', 'name_format'), 270 'name_format': metadata.get('locales', 'name_format'),
273 'file_format': metadata.get('locales', 'file_format'), 271 'file_format': metadata.get('locales', 'file_format'),
274 'target_platforms': set(metadata.get('locales',
275 'target_platforms').split()),
276 'default_locale': metadata.get('locales', 'default_locale') 272 'default_locale': metadata.get('locales', 'default_locale')
277 } 273 }
278 274
279 localeConfig['base_path'] = localeDir 275 localeConfig['base_path'] = localeDir
280 276
281 locales = [(locale, os.path.join(localeDir, locale)) 277 locales = [(locale, os.path.join(localeDir, locale))
282 for locale in os.listdir(localeDir)] 278 for locale in os.listdir(localeDir)]
283 if localeConfig['name_format'] == 'ISO-15897': 279 if localeConfig['name_format'] == 'ISO-15897':
284 locales = [(locale.replace('_', '-'), localePath) 280 locales = [(locale.replace('_', '-'), localePath)
285 for locale, localePath in locales] 281 for locale, localePath in locales]
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 key = args[0] 333 key = args[0]
338 334
339 from buildtools.packager import readMetadata 335 from buildtools.packager import readMetadata
340 metadata = readMetadata(baseDir, type) 336 metadata = readMetadata(baseDir, type)
341 337
342 basename = metadata.get('general', 'basename') 338 basename = metadata.get('general', 'basename')
343 localeConfig = readLocaleConfig(baseDir, type, metadata) 339 localeConfig = readLocaleConfig(baseDir, type, metadata)
344 340
345 import buildtools.localeTools as localeTools 341 import buildtools.localeTools as localeTools
346 for locale, localeDir in localeConfig['locales'].iteritems(): 342 for locale, localeDir in localeConfig['locales'].iteritems():
347 if locale != localeConfig['default_locale']: 343 if locale != localeConfig['default_locale'].replace('_', '-'):
348 localeTools.uploadTranslations(localeConfig, metadata, localeDir, lo cale, 344 localeTools.uploadTranslations(localeConfig, metadata, localeDir, lo cale,
349 basename, key) 345 basename, key)
350 346
351 347
352 def getTranslations(baseDir, scriptName, opts, args, type): 348 def getTranslations(baseDir, scriptName, opts, args, type):
353 if len(args) < 1: 349 if len(args) < 1:
354 print 'Project key is required to update translation master files.' 350 print 'Project key is required to update translation master files.'
355 usage(scriptName, type, 'translate') 351 usage(scriptName, type, 'translate')
356 return 352 return
357 353
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 if option in ('-h', '--help'): 600 if option in ('-h', '--help'):
605 usage(scriptName, type, command) 601 usage(scriptName, type, command)
606 sys.exit() 602 sys.exit()
607 commands[command](baseDir, scriptName, opts, args, type) 603 commands[command](baseDir, scriptName, opts, args, type)
608 else: 604 else:
609 print 'Command %s is not supported for this application type' % comm and 605 print 'Command %s is not supported for this application type' % comm and
610 usage(scriptName, type) 606 usage(scriptName, type)
611 else: 607 else:
612 print 'Command %s is unrecognized' % command 608 print 'Command %s is unrecognized' % command
613 usage(scriptName, type) 609 usage(scriptName, type)
LEFTRIGHT
« no previous file | localeTools.py » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld