Chromium Code Reviews| 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 fnmatch | |
| 6 import itertools | |
|
Yaron
2013/03/14 23:03:51
unused
cjhopman
2013/03/15 22:44:39
Done.
| |
| 5 import os | 7 import os |
| 8 import shutil | |
| 6 | 9 |
| 7 | 10 |
| 8 def EnsureDirectoryExists(dir_path): | 11 def EnsureDirectoryExists(dir_path): |
|
newt (away)
2013/03/15 03:25:04
MakeDirIfNotExists? the current name sounds asser
cjhopman
2013/03/15 22:44:39
Yeah, I didn't really like this name either... May
| |
| 9 try: | 12 try: |
| 10 os.makedirs(dir_path) | 13 os.makedirs(dir_path) |
| 11 except OSError: | 14 except OSError: |
| 12 pass | 15 pass |
| 13 | 16 |
| 14 | 17 |
| 18 def DeleteDirectory(dir_path): | |
| 19 if os.path.exists(dir_path): | |
| 20 shutil.rmtree(dir_path) | |
| 21 | |
| 22 | |
| 23 def Touch(path): | |
| 24 EnsureDirectoryExists(os.path.dirname(path)) | |
| 25 with open(path, 'a'): | |
| 26 os.utime(path, None) | |
| 27 | |
| 28 | |
| 29 def FindInDirectory(directory, filter): | |
| 30 files = [] | |
| 31 for root, dirnames, filenames in os.walk(directory): | |
| 32 files.extend(map(lambda f: os.path.join(root, f), | |
| 33 fnmatch.filter(filenames, filter))) | |
|
newt (away)
2013/03/15 03:25:04
list comprehension?
rel_files = fnmatch.filte
cjhopman
2013/03/15 22:44:39
Done.
| |
| 34 return files | |
| 35 | |
| 36 | |
| 37 def FindInDirectories(directories, filter): | |
| 38 all_files = [] | |
| 39 for directory in directories: | |
| 40 all_files.extend(FindInDirectory(directory, filter)) | |
| 41 return all_files | |
| 42 | |
| 43 | |
| 44 def ParseGypList(gyp_string): | |
|
newt (away)
2013/03/15 03:25:04
gyp_string = gyp_string.replace('##','$')
return s
cjhopman
2013/03/15 22:44:39
Oh, shlex... much nicer. Done.
| |
| 45 # With the ninja generator, some list members are in double quotes, | |
|
Yaron
2013/03/14 23:03:51
Why would we have these charcters in strings? "$"
cjhopman
2013/03/15 22:44:39
Precisely. I could find no way to escape/quote suc
| |
| 46 # some aren't. For now, this only supports a limited format for lists | |
| 47 # (i.e. no spaces or double quotes in items). | |
| 48 gyp_list = gyp_string.split() | |
| 49 gyp_list = map(lambda s: s.replace('"', ''), gyp_list) | |
| 50 # The ninja generator doesn't support $ in strings, so use ## to | |
|
newt (away)
2013/03/15 03:25:04
is there any way we can change the generator to su
cjhopman
2013/03/15 22:44:39
I agree. Updated with a gyp bug tracking this.
| |
| 51 # represent $. | |
| 52 gyp_list = map(lambda s: s.replace('##', '$'), gyp_list) | |
| 53 return gyp_list | |
| 54 | |
| 55 | |
| OLD | NEW |