Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions scripts/datamodel-doc/ALICEO2codeFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions scripts/datamodel-doc/ALICEO2dataModelTools.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
import sys
import regex as re
import numpy as np
import nltk

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = ''
Expand Down