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 contextlib | 5 import contextlib |
6 import fnmatch | 6 import fnmatch |
7 import json | 7 import json |
8 import os | 8 import os |
9 import pipes | 9 import pipes |
10 import shlex | 10 import shlex |
(...skipping 23 matching lines...) Expand all Loading... |
34 os.makedirs(dir_path) | 34 os.makedirs(dir_path) |
35 except OSError: | 35 except OSError: |
36 pass | 36 pass |
37 | 37 |
38 | 38 |
39 def DeleteDirectory(dir_path): | 39 def DeleteDirectory(dir_path): |
40 if os.path.exists(dir_path): | 40 if os.path.exists(dir_path): |
41 shutil.rmtree(dir_path) | 41 shutil.rmtree(dir_path) |
42 | 42 |
43 | 43 |
44 def Touch(path): | 44 def Touch(path, fail_if_missing=False): |
| 45 if fail_if_missing and not os.path.exists(path): |
| 46 raise Exception(path + ' doesn\'t exist.') |
| 47 |
45 MakeDirectory(os.path.dirname(path)) | 48 MakeDirectory(os.path.dirname(path)) |
46 with open(path, 'a'): | 49 with open(path, 'a'): |
47 os.utime(path, None) | 50 os.utime(path, None) |
48 | 51 |
49 | 52 |
50 def FindInDirectory(directory, filename_filter): | 53 def FindInDirectory(directory, filename_filter): |
51 files = [] | 54 files = [] |
52 for root, _dirnames, filenames in os.walk(directory): | 55 for root, _dirnames, filenames in os.walk(directory): |
53 matched_files = fnmatch.filter(filenames, filename_filter) | 56 matched_files = fnmatch.filter(filenames, filename_filter) |
54 files.extend((os.path.join(root, f) for f in matched_files)) | 57 files.extend((os.path.join(root, f) for f in matched_files)) |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 205 |
203 | 206 |
204 def PrintWarning(message): | 207 def PrintWarning(message): |
205 print 'WARNING: ' + message | 208 print 'WARNING: ' + message |
206 | 209 |
207 | 210 |
208 def PrintBigWarning(message): | 211 def PrintBigWarning(message): |
209 print '***** ' * 8 | 212 print '***** ' * 8 |
210 PrintWarning(message) | 213 PrintWarning(message) |
211 print '***** ' * 8 | 214 print '***** ' * 8 |
OLD | NEW |