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

Delta Between Two Patch Sets: localeTools.py

Issue 29336281: Issue 2109 - Allow for translation of app independent repositories (Closed)
Left Patch Set: Removed includeIncomplete parameter and fixed typo Created Feb. 12, 2016, 8:04 p.m.
Right Patch Set: Fixed typo spotted during testing Created Feb. 13, 2016, 12:31 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « build.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This Source Code Form is subject to the terms of the Mozilla Public 3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 6
7 import re, os, sys, codecs, json, urllib, urllib2 7 import re, os, sys, codecs, json, urllib, urllib2
8 from StringIO import StringIO 8 from StringIO import StringIO
9 from ConfigParser import SafeConfigParser 9 from ConfigParser import SafeConfigParser
10 from zipfile import ZipFile 10 from zipfile import ZipFile
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 result = urllib2.urlopen('http://api.crowdin.net/api/project/%s/export?key=%s' % (projectName, key)).read() 392 result = urllib2.urlopen('http://api.crowdin.net/api/project/%s/export?key=%s' % (projectName, key)).read()
393 if result.find('<success') < 0: 393 if result.find('<success') < 0:
394 raise Exception('Server indicated that the operation was not successful\n' + result) 394 raise Exception('Server indicated that the operation was not successful\n' + result)
395 395
396 result = urllib2.urlopen('http://api.crowdin.net/api/project/%s/download/all.z ip?key=%s' % (projectName, key)).read() 396 result = urllib2.urlopen('http://api.crowdin.net/api/project/%s/download/all.z ip?key=%s' % (projectName, key)).read()
397 zip = ZipFile(StringIO(result)) 397 zip = ZipFile(StringIO(result))
398 dirs = {} 398 dirs = {}
399 399
400 normalizedDefaultLocale = localeConfig['default_locale'] 400 normalizedDefaultLocale = localeConfig['default_locale']
401 if localeConfig['name_format'] == 'ISO-15897': 401 if localeConfig['name_format'] == 'ISO-15897':
402 normalizedDefaultLocale = defaultLocale.replace('_', '-') 402 normalizedDefaultLocale = normalizedDefaultLocale.replace('_', '-')
403 normalizedDefaultLocale = mapLocale(localeConfig['name_format'], 403 normalizedDefaultLocale = mapLocale(localeConfig['name_format'],
404 normalizedDefaultLocale) 404 normalizedDefaultLocale)
405 405
406 for info in zip.infolist(): 406 for info in zip.infolist():
407 if not info.filename.endswith('.json'): 407 if not info.filename.endswith('.json'):
408 continue 408 continue
409 409
410 dir, file = os.path.split(info.filename) 410 dir, file = os.path.split(info.filename)
411 if not re.match(r'^[\w\-]+$', dir) or dir == normalizedDefaultLocale: 411 if not re.match(r'^[\w\-]+$', dir) or dir == normalizedDefaultLocale:
412 continue 412 continue
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 454
455 # Remove any extra files 455 # Remove any extra files
456 for dir, files in dirs.iteritems(): 456 for dir, files in dirs.iteritems():
457 baseDir = os.path.join(localeConfig['base_path'], dir) 457 baseDir = os.path.join(localeConfig['base_path'], dir)
458 if not os.path.exists(baseDir): 458 if not os.path.exists(baseDir):
459 continue 459 continue
460 for file in os.listdir(baseDir): 460 for file in os.listdir(baseDir):
461 path = os.path.join(baseDir, file) 461 path = os.path.join(baseDir, file)
462 if os.path.isfile(path) and (file.endswith('.json') or file.endswith('.pro perties') or file.endswith('.dtd')) and not file in files: 462 if os.path.isfile(path) and (file.endswith('.json') or file.endswith('.pro perties') or file.endswith('.dtd')) and not file in files:
463 os.remove(path) 463 os.remove(path)
LEFTRIGHT
« build.py ('k') | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld