CMS 3D CMS Logo

Functions | Variables
commentSkipper.cppCommentSkipper Namespace Reference

Functions

def filterFile (file)
 
def filterFiles (fileList)
 

Variables

 __author__
 
 __date__
 

Function Documentation

◆ filterFile()

def commentSkipper.cppCommentSkipper.filterFile (   file)

Definition at line 14 of file cppCommentSkipper.py.

14 def filterFile(file): #ifstream& input)
15 
16  lines = open(file).readlines()
17  commentStage = False
18 
19  for i in range(len(lines)):
20  #for j in range(len(lines[i])):
21  j = 0
22 
23  while lines[i][j] != '\n':
24 
25  char = lines[i][j]
26  #char /
27  if char == '/':
28  #comment /*
29  if lines[i][j+1] == '*' and not commentStage: #why !commentStage? because it could be /*...../*.....*/
30  commentStage = True
31  commentStartLine, commentStartColumn = i, j
32  j += 1
33  #comment // why !commentStage? because, can be a variant of this example: /*....//.....*/
34  elif not commentStage and (lines[i][j+1] == '/'):
35  lines[i] = lines[i].replace(lines[i][j:],'\n', 1)
36  break
37  #char "
38  elif char == '"':
39  if not commentStage:
40  next = lines[i][j+1:].find('"') #next "
41  lines[i] = lines[i].replace(lines[i][j:j+next+2], '', 1) # clear string in ""
42  #char '
43  elif char == '\'':
44  if not commentStage:
45  next = lines[i][j+1:].find('\'') #next '
46  lines[i] = lines[i].replace(lines[i][j:j+next+2], '', 1) # clear string in ''
47  #char *
48  elif char == '*':
49  if (commentStage and (lines[i][j+1] == '/')):
50  commentStage = False;
51  if commentStartLine != i:
52  lines[i] = lines[i].replace(lines[i][:j+2],'', 1) # comment */ [..code]
53  j = -1 #because of j+=1 at the end
54  else:
55  lines[i] = lines[i].replace(lines[i][commentStartColumn:j+2], '', 1) # [code..] /*comment*/ [.. code]
56  j = commentStartColumn - 1 #because of j+=1 at the ends
57  if j != len(lines[i]) - 1:
58  j += 1
59  else:
60  j = 0
61  break
62  if commentStage:
63  if i == commentStartLine: lines[i] = lines[i].replace(lines[i][commentStartColumn:],'\n', 1)
64  else: lines[i] = lines[i].replace(lines[i][:], '\n')
65  return lines

References spr.find(), FastTimerService_cff.range, and python.rootplot.root2matplotlib.replace().

Referenced by commentSkipper.cppCommentSkipper.filterFiles().

◆ filterFiles()

def commentSkipper.cppCommentSkipper.filterFiles (   fileList)

Definition at line 7 of file cppCommentSkipper.py.

7 def filterFiles(fileList):
8  files = []
9 
10  for file in fileList:
11  files.append((file, filterFile(file)))
12  return files
13 

References commentSkipper.cppCommentSkipper.filterFile().

Variable Documentation

◆ __author__

commentSkipper.cppCommentSkipper.__author__
private

Definition at line 2 of file cppCommentSkipper.py.

◆ __date__

commentSkipper.cppCommentSkipper.__date__
private

Definition at line 3 of file cppCommentSkipper.py.

FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
commentSkipper.cppCommentSkipper.filterFile
def filterFile(file)
Definition: cppCommentSkipper.py:14
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
commentSkipper.cppCommentSkipper.filterFiles
def filterFiles(fileList)
Definition: cppCommentSkipper.py:7
python.rootplot.root2matplotlib.replace
def replace(string, replacements)
Definition: root2matplotlib.py:444