| OLD | NEW |
| 1 #!/usr/bin/env python |
| 2 # |
| 1 # Copyright 2015 Google Inc. | 3 # Copyright 2015 Google Inc. |
| 2 # | 4 # |
| 3 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 6 # found in the LICENSE file. |
| 5 | 7 |
| 6 ''' | 8 ''' |
| 7 find.py is a poor-man's emulation of `find -name=$1 $2` on Unix. | 9 find.py is a poor-man's emulation of `find -name=$1 $2` on Unix. |
| 8 | 10 |
| 9 Call python find.py <glob> <directory>... to list all files matching glob under | 11 Call python find.py <glob> <directory>... to list all files matching glob under |
| 10 directory (recursively). E.g. | 12 directory (recursively). E.g. |
| 11 $ python find.py '*.cpp' ../tests/ ../bench/ | 13 $ python find.py '*.cpp' ../tests/ ../bench/ |
| 12 will print all .cpp files under ../tests/ and ../bench/. | 14 will print all .cpp files under ../tests/ and ../bench/. |
| 13 ''' | 15 ''' |
| 14 | 16 |
| 15 import fnmatch | 17 import fnmatch |
| 16 import os | 18 import os |
| 17 import sys | 19 import sys |
| 18 | 20 |
| 19 for directory in sys.argv[2:]: | 21 for directory in sys.argv[2:]: |
| 20 for d, kids, files in os.walk(directory): | 22 for d, kids, files in os.walk(directory): |
| 21 files.sort() | 23 files.sort() |
| 22 for f in files: | 24 for f in files: |
| 23 if fnmatch.fnmatch(f, sys.argv[1]): | 25 if fnmatch.fnmatch(f, sys.argv[1]): |
| 24 print os.path.join(d, f).replace('\\', '/') # Gyp wants Unix paths. | 26 print os.path.join(d, f).replace('\\', '/') # Gyp wants Unix paths. |
| OLD | NEW |