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

Side by Side Diff: localeTools.py

Issue 29589613: Issue 5939 - Download translations to correct folder (Closed)
Patch Set: Created Oct. 26, 2017, 11:58 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 | no next file » | 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 re 5 import re
6 import os 6 import os
7 import sys 7 import sys
8 import codecs 8 import codecs
9 import json 9 import json
10 import urlparse 10 import urlparse
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 if not re.match(r'^[\w\-]+$', dir) or dir == normalizedDefaultLocale: 262 if not re.match(r'^[\w\-]+$', dir) or dir == normalizedDefaultLocale:
263 continue 263 continue
264 if file.count('.') == 1: 264 if file.count('.') == 1:
265 origFile = file 265 origFile = file
266 else: 266 else:
267 origFile = os.path.splitext(file)[0] 267 origFile = os.path.splitext(file)[0]
268 268
269 for key, value in CROWDIN_LANG_MAPPING.iteritems(): 269 for key, value in CROWDIN_LANG_MAPPING.iteritems():
270 if value == dir: 270 if value == dir:
271 dir = key 271 dir = key
272 dir = dir.replace('-', '_')
272 273
273 data = zip.open(info.filename).read() 274 data = zip.open(info.filename).read()
274 if data == '[]': 275 if data == '[]':
275 continue 276 continue
276 277
277 if not dir in dirs: 278 if not dir in dirs:
278 dirs[dir] = set() 279 dirs[dir] = set()
279 dirs[dir].add(origFile) 280 dirs[dir].add(origFile)
280 281
281 path = os.path.join(localeConfig['base_path'], dir, origFile) 282 path = os.path.join(localeConfig['base_path'], dir, origFile)
(...skipping 11 matching lines...) Expand all
293 # Remove any extra files 294 # Remove any extra files
294 for dir, files in dirs.iteritems(): 295 for dir, files in dirs.iteritems():
295 baseDir = os.path.join(localeConfig['base_path'], dir) 296 baseDir = os.path.join(localeConfig['base_path'], dir)
296 if not os.path.exists(baseDir): 297 if not os.path.exists(baseDir):
297 continue 298 continue
298 for file in os.listdir(baseDir): 299 for file in os.listdir(baseDir):
299 path = os.path.join(baseDir, file) 300 path = os.path.join(baseDir, file)
300 valid_extension = file.endswith('.json') 301 valid_extension = file.endswith('.json')
301 if os.path.isfile(path) and valid_extension and not file in files: 302 if os.path.isfile(path) and valid_extension and not file in files:
302 os.remove(path) 303 os.remove(path)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld