CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
buildFileCommentSkipper.py
Go to the documentation of this file.
1 __author__="Aurelija"
2 __date__ ="$2010-07-20 11.52.22$"
3 
4 import sys
5 
6 def filterFiles(fileList):
7  files = []
8 
9  for file in fileList:
10  files.append((file, filterFile(file)))
11  return files
12 
13 
14 def filterFile(file):
15  lines = open(file).readlines()
16  lines = filterMultilineComment(lines, '"""', '"""')
17  lines = filterMultilineComment(lines, "'''", "'''")
18  lines = filterMultilineComment(lines, '<!--', '-->')
19  lines = filterOneLineComment(lines, "#")
20  return lines
21 
22 
23 def filterOneLineComment(lines, commentStart):
24  for i in range(len(lines)):
25  index = lines[i].find(commentStart)
26  if index != -1:
27  lines[i] = lines[i].replace(lines[i][index:], '\n')
28  return lines
29 
30 
31 def filterMultilineComment(lines, commentStart, commentEnd):
32  i = 0
33  tlines = len(lines)
34  while (i < tlines):
35  startIndex = lines[i].find(commentStart)
36  startLine = i
37  while((startIndex != -1) and (i < tlines)):
38  endIndex = lines[i].find(commentEnd)
39  if endIndex != -1:
40  if startLine == i:
41  lines[i] = lines[i].replace(lines[i][startIndex:endIndex+3], '', 1)
42  else:
43  lines[i] = lines[i].replace(lines[i][:endIndex+3], '')
44  startIndex = lines[i].find(commentStart)
45  startLine = i
46  else:
47  if startLine == i:
48  lines[i] = lines[i].replace(lines[i][startIndex:], '\n', 1)
49  else:
50  lines[i] = lines[i].replace(lines[i][:], '\n')
51  i += 1
52  i += 1
53  return lines
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7