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