CMS 3D CMS Logo

Functions | Variables
keyFinder Namespace Reference

Functions

def find (file, regularExpression, exceptRegEx=[])
 
def finds (fileList, regularExpression, exceptRegEx=[])
 

Variables

 __author__
 
 __date__
 

Function Documentation

def keyFinder.find (   file,
  regularExpression,
  exceptRegEx = [] 
)

Definition at line 26 of file keyFinder.py.

Referenced by finds().

26 def find(file, regularExpression, exceptRegEx = []):
27  lines = []
28 
29  if type(file).__name__ != 'list':
30  fileLines = open(file).readlines()
31  else: fileLines = file
32  for i in range(len(fileLines)):
33  matchException = False
34  if re.search(regularExpression, fileLines[i]) != None:
35  for regEx in exceptRegEx:
36  if re.search(regEx, fileLines[i]) != None:
37  matchException = True
38  break
39  if not matchException:
40  lines.append(i+1)
41  return lines
42 
43 
def find(file, regularExpression, exceptRegEx=[])
Definition: keyFinder.py:26
def keyFinder.finds (   fileList,
  regularExpression,
  exceptRegEx = [] 
)

Definition at line 7 of file keyFinder.py.

References find().

Referenced by cmsCodeRulesChecker.runRules().

7 def finds(fileList, regularExpression, exceptRegEx = []):
8  info = []
9  lines = []
10 
11  for i in range(len(fileList)):
12  if type(fileList[0]).__name__ != 'tuple':
13  file = fileList[i]
14  lines = find(fileList[i], regularExpression, exceptRegEx)
15  else:
16  file = fileList[i][0]
17  lines = find(fileList[i][1], regularExpression, exceptRegEx)
18 
19  if lines:
20  info.append((file, lines))
21 
22  return info
23 
24 #file is the file path or the list of file lines
25 #exceptRegEx is the list of regular expressions that says to skip line if one of these regEx matches
def find(file, regularExpression, exceptRegEx=[])
Definition: keyFinder.py:26
def finds(fileList, regularExpression, exceptRegEx=[])
Definition: keyFinder.py:7

Variable Documentation

keyFinder.__author__
private

Definition at line 1 of file keyFinder.py.

keyFinder.__date__
private

Definition at line 2 of file keyFinder.py.