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

Delta Between Two Patch Sets: packagerGecko.py

Issue 6590020945182720: Issue 1707 - Allow importing Chrome-style locales in Firefox extensions (Closed)
Left Patch Set: Created Dec. 16, 2014, 10:42 p.m.
Right Patch Set: Addressed comment Created Dec. 17, 2014, 1:25 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 | « no previous file | 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 os 7 import os
8 import sys 8 import sys
9 import re 9 import re
10 import hashlib 10 import hashlib
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 baseDir = params['baseDir'] 57 baseDir = params['baseDir']
58 for file in os.listdir(baseDir): 58 for file in os.listdir(baseDir):
59 if file.endswith('.js') or file.endswith('.xml'): 59 if file.endswith('.js') or file.endswith('.xml'):
60 result.add(file) 60 result.add(file)
61 return result 61 return result
62 62
63 def getIgnoredFiles(params): 63 def getIgnoredFiles(params):
64 return {'.incomplete', 'meta.properties'} 64 return {'.incomplete', 'meta.properties'}
65 65
66 def archive_path(path, baseDir): 66 def archive_path(path, baseDir):
67 return '/'.join(os.path.relpath(path, baseDir).split(os.sep)) 67 return '/'.join(os.path.split(os.path.relpath(path, baseDir)))
Sebastian Noack 2014/12/17 08:18:12 Nit: x.split(os.sep) -> os.path.split(x)
Wladimir Palant 2014/12/17 13:26:04 Done.
68 68
69 def isValidLocale(localesDir, dir, includeIncomplete=False): 69 def isValidLocale(localesDir, dir, includeIncomplete=False):
70 if re.search(r'[^\w\-]', dir): 70 if re.search(r'[^\w\-]', dir):
71 return False 71 return False
72 curLocaleDir = os.path.join(localesDir, dir) 72 curLocaleDir = os.path.join(localesDir, dir)
73 if not os.path.isdir(curLocaleDir): 73 if not os.path.isdir(curLocaleDir):
74 return False 74 return False
75 if len(os.listdir(curLocaleDir)) == 0: 75 if len(os.listdir(curLocaleDir)) == 0:
76 return False 76 return False
77 if not includeIncomplete and os.path.exists(os.path.join(localesDir, dir, '.in complete')): 77 if not includeIncomplete and os.path.exists(os.path.join(localesDir, dir, '.in complete')):
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 if not params['metadata'].has_section(SECTION): 158 if not params['metadata'].has_section(SECTION):
159 return 159 return
160 160
161 import localeTools 161 import localeTools
162 162
163 for locale in params['locales']: 163 for locale in params['locales']:
164 for item in params['metadata'].items(SECTION): 164 for item in params['metadata'].items(SECTION):
165 path, keys = item 165 path, keys = item
166 parts = [locale if p == '*' else p for p in path.split('/')] 166 parts = [locale if p == '*' else p for p in path.split('/')]
167 source = os.path.join(os.path.dirname(item.source), *parts) 167 source = os.path.join(os.path.dirname(item.source), *parts)
168 if not os.path.exists(source): 168 if not os.path.exists(source):
Sebastian Noack 2014/12/17 08:18:12 Nit: I'd prefer to catch the IOError when openenin
Wladimir Palant 2014/12/17 13:26:04 Sure, but that's not a scenario where race conditi
Sebastian Noack 2014/12/17 13:59:07 Theoretically, the contents of the file system can
169 continue 169 continue
170 170
171 with io.open(source, 'r', encoding='utf-8') as handle: 171 with io.open(source, 'r', encoding='utf-8') as handle:
172 data = json.load(handle) 172 data = json.load(handle)
173 173
174 target_name = os.path.splitext(os.path.basename(source))[0] + '.properties ' 174 target_name = os.path.splitext(os.path.basename(source))[0] + '.properties '
175 target = archive_path(os.path.join(getLocalesDir(params['baseDir']), local e, target_name), params['baseDir']) 175 target = archive_path(os.path.join(getLocalesDir(params['baseDir']), local e, target_name), params['baseDir'])
176 176
177 files[target] = '' 177 files[target] = ''
178 for key, value in sorted(data.items()): 178 for key, value in sorted(data.items()):
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 if metadata.has_section('preprocess'): 354 if metadata.has_section('preprocess'):
355 files.preprocess([f for f, _ in metadata.items('preprocess')]) 355 files.preprocess([f for f, _ in metadata.items('preprocess')])
356 if keyFile: 356 if keyFile:
357 signFiles(files, keyFile) 357 signFiles(files, keyFile)
358 files.zip(outFile, sortKey=lambda x: '!' if x == 'META-INF/zigbert.rsa' else x ) 358 files.zip(outFile, sortKey=lambda x: '!' if x == 'META-INF/zigbert.rsa' else x )
359 359
360 def autoInstall(baseDir, type, host, port, multicompartment=False): 360 def autoInstall(baseDir, type, host, port, multicompartment=False):
361 fileBuffer = StringIO() 361 fileBuffer = StringIO()
362 createBuild(baseDir, type=type, outFile=fileBuffer, multicompartment=multicomp artment) 362 createBuild(baseDir, type=type, outFile=fileBuffer, multicompartment=multicomp artment)
363 urllib.urlopen('http://%s:%s/' % (host, port), data=fileBuffer.getvalue()) 363 urllib.urlopen('http://%s:%s/' % (host, port), data=fileBuffer.getvalue())
LEFTRIGHT
« no previous file | 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