Go to the documentation of this file.00001 __author__="Aurelija"
00002 __date__ ="$Jul 12, 2010 10:08:20 AM$"
00003
00004 import re
00005
00006
00007 def finds(fileList, regularExpression, exceptRegEx = []):
00008 info = []
00009 lines = []
00010
00011 for i in range(len(fileList)):
00012 if type(fileList[0]).__name__ != 'tuple':
00013 file = fileList[i]
00014 lines = find(fileList[i], regularExpression, exceptRegEx)
00015 else:
00016 file = fileList[i][0]
00017 lines = find(fileList[i][1], regularExpression, exceptRegEx)
00018
00019 if lines:
00020 info.append((file, lines))
00021
00022 return info
00023
00024
00025
00026 def find(file, regularExpression, exceptRegEx = []):
00027 lines = []
00028
00029 if type(file).__name__ != 'list':
00030 fileLines = open(file).readlines()
00031 else: fileLines = file
00032 for i in range(len(fileLines)):
00033 matchException = False
00034 if re.search(regularExpression, fileLines[i]) != None:
00035 for regEx in exceptRegEx:
00036 if re.search(regEx, fileLines[i]) != None:
00037 matchException = True
00038 break
00039 if not matchException:
00040 lines.append(i+1)
00041 return lines
00042