diff --git a/scripts/datamodel-doc/ALICEO2codeFile.py b/scripts/datamodel-doc/ALICEO2codeFile.py index cfbacb7a0189c..a5f861280d00b 100644 --- a/scripts/datamodel-doc/ALICEO2codeFile.py +++ b/scripts/datamodel-doc/ALICEO2codeFile.py @@ -99,7 +99,23 @@ def parseContent(self, content): inds = [i for i, x in enumerate(words) if x.txt == 'template'] for ind in inds: line = O2DMT.block(words[ind:]) - tempBlock = O2DMT.lineInBrackets("{","}",line,True) + + # templates can come without {} block! + # find out what comes first '{' or ';' + if ';' in line: + ci = line.index(';') + o1 = ci+1 + if '{' in line: + o1 = line.index('{') + if ci < o1: + tempBlock = line[:ci] + else: + [oi, ci] = O2DMT.findInBrackets("{","}",line) + tempBlock = line[:ci] + else: + [oi, ci] = O2DMT.findInBrackets("{","}",line) + tempBlock = line[:ci] + if len(tempBlock) == 0: continue @@ -108,7 +124,9 @@ def parseContent(self, content): argWords = tempLine.split(',') tempArgs = list() for arg in argWords: - tempArgs.append(arg.split()[-1]) + kvpair = arg.split() + if len(kvpair) == 2: + tempArgs.append(kvpair[-1]) # find struct within tempBlock tempWords = O2DMT.split(tempBlock) @@ -133,7 +151,6 @@ def parseContent(self, content): # update restLine eob = nchFullLine - len(line) restLine += fullLine[sob:eob] - [oi, ci] = O2DMT.findInBrackets("{","}",line) sob = eob+ci+1 # update restLine diff --git a/scripts/datamodel-doc/ALICEO2dataModelTools.py b/scripts/datamodel-doc/ALICEO2dataModelTools.py index f41076434cf03..458edafb1dbf5 100644 --- a/scripts/datamodel-doc/ALICEO2dataModelTools.py +++ b/scripts/datamodel-doc/ALICEO2dataModelTools.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import sys +import regex as re import numpy as np import nltk @@ -88,7 +89,7 @@ def expandLine(self, line): for ind1 in range(len(self.vars)): for ind2 in range(len(words)): if self.vars[ind1].strip() in words[ind2]: - words[ind2] = vars[ind1].strip() + words[ind2] = re.sub(self.vars[ind1].strip(), vars[ind1].strip(), words[ind2]) expandedLine = block(words) # remove ##, which connects two strings @@ -172,10 +173,10 @@ def countBrackets(obr, cbr, line): # find text in closed brackets # number of closing brackets matches the number of previously opening brackets # obr/cbr: openening/closing brackets -# brackets can include more than on character +# brackets can include more than one character # line: string -# withheader: all textfrom the beginning until closing brackets match -# return modified line and int stat +# withheader: all text from the beginning until closing brackets match +# return begin/end position of brackets def findInBrackets(obr, cbr, line): newline = ''