Update ooo320-m1
[ooovba.git] / ucb / source / ucp / ftp / test.py
blob931d9a3ec8a5602be34b9e1aa32c08345f7af6f9
1 #/usr/bin/env python
3 import re,os
5 def grep(pattern,dirname,names):
6 for name in names:
7 filename = os.path.join(dirname,name)
8 if os.path.isfile(filename):
9 lines = open(filename,"r").readlines()
10 for line in lines:
11 if pattern.search(line):
12 print filename
13 break
16 def find(pattern,directory = "."):
17 os.path.walk(directory,grep,re.compile(pattern))
20 if __name__ == "__main__":
21 import sys
22 if len(sys.argv) == 2:
23 find(sys.argv[1])
24 elif len(sys.argv) == 2:
25 find(sys.argv[2],sys.argv[1])