Skip to content

Commit fa3dc2f

Browse files
authored
Update of datamodel-doc (#12487)
. proper treatment of some nested defines . accepts table declarations without ending ';'
1 parent 05cd7f6 commit fa3dc2f

File tree

3 files changed

+39
-26
lines changed

3 files changed

+39
-26
lines changed

scripts/datamodel-doc/ALICEO2dataModelTools.py

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,32 @@ def expandLine(self, line):
7474
# no substitution of variables needed
7575
expandedLine = line.replace(self.name, self.cont)
7676
else:
77-
# substitute variables vars
78-
vars = "".join(line.split("(")[1:]).split(")")[0].split(",")
79-
if len(vars) != len(self.vars):
80-
print("ATTENTION")
81-
print("Substitution error!")
82-
print("")
83-
self.print()
84-
print("")
85-
print(" ", line)
86-
87-
else:
88-
words = split(self.cont)
89-
for ind1 in range(len(self.vars)):
90-
for ind2 in range(len(words)):
91-
if self.vars[ind1].strip() in words[ind2]:
92-
words[ind2] = re.sub(self.vars[ind1].strip(), vars[ind1].strip(), words[ind2])
93-
expandedLine = block(words)
77+
inds = [i for i in range(len(line)) if line.startswith(self.name, i)]
78+
expandedLine = line[:inds[0]]
79+
for i, ind in enumerate(inds):
80+
81+
# make sure that the name of the define == self.name and not only starts with self.name
82+
words = line[ind:].split('(')
83+
if words[0].strip() != self.name:
84+
if i < len(inds)-1:
85+
expandedLine += line[ind:inds[i+1]]
86+
else:
87+
expandedLine += line[ind:]
88+
continue
89+
90+
# substitute variables vars
91+
vars = "".join(line[ind:].split("(")[1:]).split(")")[0].split(",")
92+
if len(vars) != len(self.vars):
93+
print("ATTENTION")
94+
print("Substitution error!")
95+
print('>> ', line)
96+
else:
97+
words = split(self.cont)
98+
for ind1 in range(len(self.vars)):
99+
for ind2 in range(len(words)):
100+
if self.vars[ind1].strip() in words[ind2]:
101+
words[ind2] = re.sub(self.vars[ind1].strip(), vars[ind1].strip(), words[ind2])
102+
expandedLine += block(words)
94103

95104
# remove ##, which connects two strings
96105
expandedLine = block(split(expandedLine.replace(" # # ", "")))
@@ -324,8 +333,7 @@ def pickContent(lines_in_file):
324333
linesWithoutComments[ind] = res[1]
325334

326335
# select all lines starting with #define
327-
idfs = [l for l, s in enumerate(
328-
linesWithoutComments) if s.lstrip().startswith("#define")][::-1]
336+
idfs = [l for l, s in enumerate(linesWithoutComments) if s.lstrip().startswith("#define")]
329337
for idf in idfs:
330338
ws = split(linesWithoutComments[idf])
331339
defstring = linesWithoutComments[idf].split(ws[2], 1)[1]
@@ -334,8 +342,7 @@ def pickContent(lines_in_file):
334342
# find the corresponding #undef
335343
# if no #undef then apply to the end of the file
336344
iend = len(linesWithoutComments)
337-
iudfs = [l for l, s in enumerate(
338-
linesWithoutComments) if s.lstrip().startswith("#undef")][::-1]
345+
iudfs = [l for l, s in enumerate(linesWithoutComments) if s.lstrip().startswith("#undef")]
339346
for iudf in iudfs:
340347
ws = split(linesWithoutComments[iudf])
341348
if ws[2] == df.name:

scripts/datamodel-doc/ALICEO2includeFile.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,9 +921,15 @@ def condition(s):
921921
for icol in inds:
922922
iend = [i for i, x in enumerate(
923923
O2DMT.list_in([")", ";"], words[icol:])) if x == True]
924+
iend1 = [i for i, x in enumerate(
925+
O2DMT.list_in([")"], words[icol:])) if x == True]
924926
if len(iend) == 0:
925-
print(nslevel)
926-
sys.exit('Ending ); not found in table declaration! EXIT -->')
927+
if len(iend1) == 0:
928+
print(iend1)
929+
print(lines)
930+
sys.exit('Ending ); not found in table declaration! EXIT -->')
931+
else:
932+
iend = iend1
927933
cont = words[icol:iend[0]+icol+2]
928934

929935
kind = [i for i, x in enumerate(types) if x == words[icol].txt][0]

scripts/datamodel-doc/inputCard.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@
103103
o2::aod::BCs, o2::aod::Timestamps, o2::aod::Collisions
104104
</category>
105105
<category name="Tracks">
106-
o2::aod::Tracks, o2::aod::TracksIU, o2::aod::TracksCov, o2::aod::TracksCovIU, o2::aod::TracksExtra, o2::aod::StoredTracks, o2::aod::StoredTracksIU, o2::aod::StoredTracksCov, o2::aod::StoredTracksCovIU, o2::aod::StoredTracksExtra, o2::aod::MFTTracks, o2::aod::StoredMFTTracks, o2::aod::FwdTracks, o2::aod::FwdTracksCov, o2::aod::StoredFwdTracks, o2::aod::StoredFwdTracksCov, o2::aod::AmbiguousTracks, o2::aod::AmbiguousMFTTracks, o2::aod::AmbiguousFwdTracks
106+
o2::aod::Tracks, o2::aod::TracksIU, o2::aod::TracksCov, o2::aod::TracksCovIU, o2::aod::TracksExtra, o2::aod::StoredTracks, o2::aod::StoredTracksIU, o2::aod::StoredTracksCov, o2::aod::StoredTracksCovIU, o2::aod::StoredTracksExtra, o2::aod::MFTTracks, o2::aod::StoredMFTTracks, o2::aod::FwdTracks, o2::aod::FwdTracksCov, o2::aod::StoredFwdTracks, o2::aod::StoredFwdTracksCov, o2::aod::FwdTrkCls, o2::aod::AmbiguousTracks, o2::aod::AmbiguousMFTTracks, o2::aod::AmbiguousFwdTracks
107107
</category>
108108
<category name="Detectors">
109-
o2::aod::FV0As, o2::aod::FT0s, o2::aod::FDDs, so2::aod::HMPIDs, o2::aod::Calos, o2::aod::CaloTriggers, o2::aod::Zdcs, o2::aod::FV0Cs, o2::aod::HMPIDs, o2::aod::CPVClusters, o2::aod::FwdTrkCls
109+
o2::aod::FV0As, o2::aod::FT0s, o2::aod::FDDs, so2::aod::HMPIDs, o2::aod::Calos, o2::aod::CaloTriggers, o2::aod::Zdcs, o2::aod::FV0Cs, o2::aod::HMPIDs, o2::aod::CPVClusters, o2::aod::HMPID
110110
</category>
111111
<category name="Strangeness">
112-
o2::aod::V0s, o2::aod::TransientV0s, o2::aod::StoredV0s, o2::aod::Cascades, o2::aod::TransientCascades, o2::aod::StoredCascades, o2::aod::Decays3Body
112+
o2::aod::V0s, o2::aod::TransientV0s, o2::aod::StoredV0s, o2::aod::TrackedV0s, o2::aod::Cascades, o2::aod::TransientCascades, o2::aod::StoredCascades, o2::aod::TrackedCascades, o2::aod::Decay3Bodys, o2::aod::Tracked3Bodys
113113
</category>
114114
<category name="Indices">
115115
o2::aod::Run3MatchedExclusive, o2::aod::Run3MatchedSparse, o2::aod::MatchedBCCollisionsExclusive, o2::aod::MatchedBCCollisionsSparse, o2::aod::Run3MatchedToBCExclusive, o2::aod::Run3MatchedToBCSparse, o2::aod::MatchedBCCollisionsExclusiveMulti, o2::aod::MatchedBCCollisionsSparseMulti

0 commit comments

Comments
 (0)