CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
commentSkipper.cppCommentSkipper Namespace Reference

Functions

def filterFile
 
def filterFiles
 

Variables

string __author__ = "Aurelija"
 
string __date__ = "$2010-07-13 12.17.20$"
 

Function Documentation

def commentSkipper.cppCommentSkipper.filterFile (   file)

Definition at line 14 of file cppCommentSkipper.py.

References spr.find(), sistrip::SpyUtilities.range(), and python.rootplot.root2matplotlib.replace().

Referenced by commentSkipper.cppCommentSkipper.filterFiles().

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

Definition at line 7 of file cppCommentSkipper.py.

References commentSkipper.cppCommentSkipper.filterFile().

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

Variable Documentation

string commentSkipper.cppCommentSkipper.__author__ = "Aurelija"

Definition at line 2 of file cppCommentSkipper.py.

string commentSkipper.cppCommentSkipper.__date__ = "$2010-07-13 12.17.20$"

Definition at line 3 of file cppCommentSkipper.py.