Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: mojo/public/tools/bindings/pylib/mojom_tests/support/find_files.py

Issue 443293003: Mojo: Add PRESUBMIT.py to mojo/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 from fnmatch import filter 5 import fnmatch
6 from os import walk 6 from os import walk
7 from os.path import join 7 from os.path import join
8 import sys 8 import sys
9 9
10 10
11 def FindFiles(top, pattern, **kwargs): 11 def FindFiles(top, pattern, **kwargs):
12 """Finds files under |top| matching the glob pattern |pattern|, returning a 12 """Finds files under |top| matching the glob pattern |pattern|, returning a
13 list of paths.""" 13 list of paths."""
14 matches = [] 14 matches = []
15 for dirpath, _, filenames in walk(top, **kwargs): 15 for dirpath, _, filenames in walk(top, **kwargs):
16 for filename in filter(filenames, pattern): 16 for filename in fnmatch.filter(filenames, pattern):
17 matches.append(join(dirpath, filename)) 17 matches.append(join(dirpath, filename))
18 return matches 18 return matches
19 19
20 20
21 def main(argv): 21 def main(argv):
22 if len(argv) != 3: 22 if len(argv) != 3:
23 print "usage: %s path pattern" % argv[0] 23 print "usage: %s path pattern" % argv[0]
24 return 1 24 return 1
25 25
26 for filename in FindFiles(argv[1], argv[2]): 26 for filename in FindFiles(argv[1], argv[2]):
27 print filename 27 print filename
28 return 0 28 return 0
29 29
30 30
31 if __name__ == '__main__': 31 if __name__ == '__main__':
32 sys.exit(main(sys.argv)) 32 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom_tests/parse/run_translate.py ('k') | mojo/tools/generate_java_callback_interfaces.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698