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