| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import ast | 5 import ast |
| 6 import contextlib | 6 import contextlib |
| 7 import fnmatch | 7 import fnmatch |
| 8 import json | 8 import json |
| 9 import os | 9 import os |
| 10 import pipes | 10 import pipes |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 def ZipDir(output, base_dir): | 225 def ZipDir(output, base_dir): |
| 226 with zipfile.ZipFile(output, 'w') as outfile: | 226 with zipfile.ZipFile(output, 'w') as outfile: |
| 227 for root, _, files in os.walk(base_dir): | 227 for root, _, files in os.walk(base_dir): |
| 228 for f in files: | 228 for f in files: |
| 229 path = os.path.join(root, f) | 229 path = os.path.join(root, f) |
| 230 archive_path = os.path.relpath(path, base_dir) | 230 archive_path = os.path.relpath(path, base_dir) |
| 231 CheckZipPath(archive_path) | 231 CheckZipPath(archive_path) |
| 232 outfile.write(path, archive_path) | 232 outfile.write(path, archive_path) |
| 233 | 233 |
| 234 | 234 |
| 235 def MergeZips(output, inputs, exclude_patterns=None): |
| 236 def Allow(name): |
| 237 if exclude_patterns is not None: |
| 238 for p in exclude_patterns: |
| 239 if fnmatch.fnmatch(name, p): |
| 240 return False |
| 241 return True |
| 242 |
| 243 with zipfile.ZipFile(output, 'w') as out_zip: |
| 244 for in_file in inputs: |
| 245 with zipfile.ZipFile(in_file, 'r') as in_zip: |
| 246 for name in in_zip.namelist(): |
| 247 if Allow(name): |
| 248 out_zip.writestr(name, in_zip.read(name)) |
| 249 |
| 250 |
| 235 def PrintWarning(message): | 251 def PrintWarning(message): |
| 236 print 'WARNING: ' + message | 252 print 'WARNING: ' + message |
| 237 | 253 |
| 238 | 254 |
| 239 def PrintBigWarning(message): | 255 def PrintBigWarning(message): |
| 240 print '***** ' * 8 | 256 print '***** ' * 8 |
| 241 PrintWarning(message) | 257 PrintWarning(message) |
| 242 print '***** ' * 8 | 258 print '***** ' * 8 |
| 243 | 259 |
| 244 | 260 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 file_jsons[file_path] = ReadJson(file_path) | 362 file_jsons[file_path] = ReadJson(file_path) |
| 347 | 363 |
| 348 expansion = file_jsons[file_path] | 364 expansion = file_jsons[file_path] |
| 349 for k in lookup_path[1:]: | 365 for k in lookup_path[1:]: |
| 350 expansion = expansion[k] | 366 expansion = expansion[k] |
| 351 | 367 |
| 352 new_args[i] = arg[:match.start()] + str(expansion) | 368 new_args[i] = arg[:match.start()] + str(expansion) |
| 353 | 369 |
| 354 return new_args | 370 return new_args |
| 355 | 371 |
| OLD | NEW |