ATLAS Offline Software
Generators
PMGSystematicsTools
local
bin
makeTOC.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2
3
import
os,sys
4
5
inFile=
"README.md"
6
if
len(sys.argv) >1:
7
inFile=sys.argv[1]
8
9
f =
open
(inFile)
10
11
regularLines=[]
12
tocLines=[]
13
14
afterBreak=
False
15
afterTOC=
False
16
inCodeBlock=
False
17
18
for
line
in
f.readlines():
19
if
'```'
in
line: inCodeBlock=
not
inCodeBlock
20
if
'<br/>'
in
line:
21
afterBreak=
True
22
if
'Table of Contents:'
in
line:
23
regularLines+=[line]
24
afterTOC=
True
25
if
not
(afterTOC
and
not
afterBreak): regularLines+=[line]
26
27
if
'#'
==line[0]
and
afterBreak
and
not
inCodeBlock:
28
header=line.split(
'#'
)[-1].strip()
29
tag=
'#'
+header.lower().
replace
(
" "
,
"-"
).
replace
(
","
,
""
).
replace
(
"?"
,
""
).
replace
(
"("
,
""
).
replace
(
")"
,
""
).
replace
(
"/"
,
""
)
30
nIndents=line.count(
'#'
)
31
tocLine=
""
32
for
i
in
range
(nIndents-1):
33
tocLine+=
"\t"
34
tocLine+=
"- [%s](%s)\n"
%(header,tag)
35
tocLines+=[tocLine]
36
37
fOut = open (inFile+
".tmp"
,
'w'
)
38
39
for
rl
in
regularLines:
40
fOut.write(rl)
41
if
(
'Table of Contents:'
)
in
rl:
42
for
tl
in
tocLines:
43
fOut.write(tl)
44
45
os.system(
'mv %s %s'
%(inFile+
".tmp"
,inFile))
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition:
hcg.cxx:307
plotBeamSpotVxVal.range
range
Definition:
plotBeamSpotVxVal.py:195
Trk::open
@ open
Definition:
BinningType.h:40
Generated on Thu Nov 7 2024 21:20:23 for ATLAS Offline Software by
1.8.18