2015-05-16 22:47:10 +00:00
|
|
|
# Copyright 2015 Google Inc.
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
'''
|
2016-08-02 21:28:26 +00:00
|
|
|
find.py is a poor-man's emulation of `find -name=$1 $2` on Unix.
|
2015-05-16 22:47:10 +00:00
|
|
|
|
2016-08-02 21:28:26 +00:00
|
|
|
Call python find.py <glob> <directory>... to list all files matching glob under
|
2015-05-16 22:47:10 +00:00
|
|
|
directory (recursively). E.g.
|
2016-08-02 21:28:26 +00:00
|
|
|
$ python find.py '*.cpp' ../tests/ ../bench/
|
|
|
|
will print all .cpp files under ../tests/ and ../bench/.
|
2015-05-16 22:47:10 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
import fnmatch
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2016-08-02 21:28:26 +00:00
|
|
|
for directory in sys.argv[2:]:
|
|
|
|
for d, kids, files in os.walk(directory):
|
|
|
|
files.sort()
|
|
|
|
for f in files:
|
|
|
|
if fnmatch.fnmatch(f, sys.argv[1]):
|
|
|
|
print os.path.join(d, f).replace('\\', '/') # Gyp wants Unix paths.
|