| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 if pattern is not None: | 208 if pattern is not None: |
| 209 if not fnmatch.fnmatch(name, pattern): | 209 if not fnmatch.fnmatch(name, pattern): |
| 210 continue | 210 continue |
| 211 CheckZipPath(name) | 211 CheckZipPath(name) |
| 212 if no_clobber: | 212 if no_clobber: |
| 213 output_path = os.path.join(path, name) | 213 output_path = os.path.join(path, name) |
| 214 if os.path.exists(output_path): | 214 if os.path.exists(output_path): |
| 215 raise Exception( | 215 raise Exception( |
| 216 'Path already exists from zip: %s %s %s' | 216 'Path already exists from zip: %s %s %s' |
| 217 % (zip_path, name, output_path)) | 217 % (zip_path, name, output_path)) |
| 218 | 218 z.extract(name, path) |
| 219 z.extractall(path=path) | |
| 220 | 219 |
| 221 | 220 |
| 222 def DoZip(inputs, output, base_dir=None): | 221 def DoZip(inputs, output, base_dir=None): |
| 223 """Creates a zip file from a list of files. | 222 """Creates a zip file from a list of files. |
| 224 | 223 |
| 225 Args: | 224 Args: |
| 226 inputs: A list of paths to zip, or a list of (zip_path, fs_path) tuples. | 225 inputs: A list of paths to zip, or a list of (zip_path, fs_path) tuples. |
| 227 output: Destination .zip file. | 226 output: Destination .zip file. |
| 228 base_dir: Prefix to strip from inputs. | 227 base_dir: Prefix to strip from inputs. |
| 229 """ | 228 """ |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 file_jsons[file_path] = ReadJson(file_path) | 392 file_jsons[file_path] = ReadJson(file_path) |
| 394 | 393 |
| 395 expansion = file_jsons[file_path] | 394 expansion = file_jsons[file_path] |
| 396 for k in lookup_path[1:]: | 395 for k in lookup_path[1:]: |
| 397 expansion = expansion[k] | 396 expansion = expansion[k] |
| 398 | 397 |
| 399 new_args[i] = arg[:match.start()] + str(expansion) | 398 new_args[i] = arg[:match.start()] + str(expansion) |
| 400 | 399 |
| 401 return new_args | 400 return new_args |
| 402 | 401 |
| OLD | NEW |