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 10 matching lines...) Expand all Loading... |
21 import md5_check # pylint: disable=relative-import | 21 import md5_check # pylint: disable=relative-import |
22 | 22 |
23 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) | 23 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) |
24 from pylib.constants import host_paths | 24 from pylib.constants import host_paths |
25 | 25 |
26 COLORAMA_ROOT = os.path.join(host_paths.DIR_SOURCE_ROOT, | 26 COLORAMA_ROOT = os.path.join(host_paths.DIR_SOURCE_ROOT, |
27 'third_party', 'colorama', 'src') | 27 'third_party', 'colorama', 'src') |
28 # aapt should ignore OWNERS files in addition the default ignore pattern. | 28 # aapt should ignore OWNERS files in addition the default ignore pattern. |
29 AAPT_IGNORE_PATTERN = ('!OWNERS:!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:' + | 29 AAPT_IGNORE_PATTERN = ('!OWNERS:!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:' + |
30 '!CVS:!thumbs.db:!picasa.ini:!*~:!*.d.stamp') | 30 '!CVS:!thumbs.db:!picasa.ini:!*~:!*.d.stamp') |
31 HERMETIC_TIMESTAMP = (2001, 1, 1, 0, 0, 0) | 31 _HERMETIC_TIMESTAMP = (2001, 1, 1, 0, 0, 0) |
32 _HERMETIC_FILE_ATTR = (0644 << 16L) | 32 _HERMETIC_FILE_ATTR = (0644 << 16L) |
33 | 33 |
34 | 34 |
35 @contextlib.contextmanager | 35 @contextlib.contextmanager |
36 def TempDir(): | 36 def TempDir(): |
37 dirname = tempfile.mkdtemp() | 37 dirname = tempfile.mkdtemp() |
38 try: | 38 try: |
39 yield dirname | 39 yield dirname |
40 finally: | 40 finally: |
41 shutil.rmtree(dirname) | 41 shutil.rmtree(dirname) |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 zip_file: ZipFile instance to add the file to. | 260 zip_file: ZipFile instance to add the file to. |
261 zip_path: Destination path within the zip file. | 261 zip_path: Destination path within the zip file. |
262 src_path: Path of the source file. Mutually exclusive with |data|. | 262 src_path: Path of the source file. Mutually exclusive with |data|. |
263 data: File data as a string. | 263 data: File data as a string. |
264 compress: Whether to enable compression. Default is take from ZipFile | 264 compress: Whether to enable compression. Default is take from ZipFile |
265 constructor. | 265 constructor. |
266 """ | 266 """ |
267 assert (src_path is None) != (data is None), ( | 267 assert (src_path is None) != (data is None), ( |
268 '|src_path| and |data| are mutually exclusive.') | 268 '|src_path| and |data| are mutually exclusive.') |
269 CheckZipPath(zip_path) | 269 CheckZipPath(zip_path) |
270 zipinfo = zipfile.ZipInfo(filename=zip_path, date_time=HERMETIC_TIMESTAMP) | 270 zipinfo = zipfile.ZipInfo(filename=zip_path, date_time=_HERMETIC_TIMESTAMP) |
271 zipinfo.external_attr = _HERMETIC_FILE_ATTR | 271 zipinfo.external_attr = _HERMETIC_FILE_ATTR |
272 | 272 |
273 if src_path and os.path.islink(src_path): | 273 if src_path and os.path.islink(src_path): |
274 zipinfo.filename = zip_path | 274 zipinfo.filename = zip_path |
275 zipinfo.external_attr |= stat.S_IFLNK << 16L # mark as a symlink | 275 zipinfo.external_attr |= stat.S_IFLNK << 16L # mark as a symlink |
276 zip_file.writestr(zipinfo, os.readlink(src_path)) | 276 zip_file.writestr(zipinfo, os.readlink(src_path)) |
277 return | 277 return |
278 | 278 |
279 if src_path: | 279 if src_path: |
280 with file(src_path) as f: | 280 with file(src_path) as f: |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 | 528 |
529 md5_check.CallAndRecordIfStale( | 529 md5_check.CallAndRecordIfStale( |
530 on_stale_md5, | 530 on_stale_md5, |
531 record_path=record_path, | 531 record_path=record_path, |
532 input_paths=input_paths, | 532 input_paths=input_paths, |
533 input_strings=input_strings, | 533 input_strings=input_strings, |
534 output_paths=output_paths, | 534 output_paths=output_paths, |
535 force=force, | 535 force=force, |
536 pass_changes=True) | 536 pass_changes=True) |
537 | 537 |
OLD | NEW |