forked from sirikata/sirikata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sgrep.py
executable file
·51 lines (42 loc) · 1.35 KB
/
sgrep.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python
import subprocess
import sys
import os.path
# These are generic rules that should only match on the individual
# directory name (rather than the entire path, e.g. bar in
# /foo/bar). These should be used rarely since they can end up
# accidentally block other directories (e.g. putting in 'scripts'
# would block out both the top-level scripts directory and Emerson
# scripts).
RELATIVE_EXCLUDES = [
'.git'
]
# These are 'absolute' paths, w.r.t. the top Sirikata directory
ABSOLUTE_EXCLUDES = [
'dependencies',
'externals',
'scripts',
'build/cmake',
'build/Frameworks',
'doc',
'docs',
'liboh/plugins/ogre/data/ace',
'liboh/plugins/ogre/data/labjs',
'liboh/plugins/ogre/data/jquery_themes',
'liboh/plugins/ogre/data/jquery_plugins',
'liboh/plugins/ogre/data/jquery',
'liboh/plugins/js/emerson/alt_regress',
'liboh/plugins/js/emerson/regression'
]
if __name__ == "__main__":
if (len (sys.argv) < 2):
print("Usage: sgrep.py pattern")
sirikata_dir = os.path.abspath(os.path.dirname(__file__))
excludes = []
excludes += RELATIVE_EXCLUDES
excludes += [os.path.join(sirikata_dir, p) for p in ABSOLUTE_EXCLUDES]
cmd = ['grep', '-R']
cmd += [ '--exclude-dir=' + e for e in excludes ]
cmd += sys.argv[1:]
cmd += [ sirikata_dir ]
subprocess.call(cmd);