Skip to content
Snippets Groups Projects
Commit 75f3da9e authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

added tool to generate a wiki table from the variable household XML file

parent 66ac9fb8
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/python3
import xml.etree.ElementTree as ET
def findCommonPrefix(string1, string2):
length = min( len(string1), len(string2) )
for i in range(length):
if string1[i] != string2[i] :
return string1[0:i-1]
if len(string1) < len(string2) :
return string1
else :
return string2
def parseDirectory(directory, cwd, stripDescriptionPrefix) :
for elem in directory.findall("{https://github.com/ChimeraTK/ApplicationCore}variable") :
varname = elem.attrib["name"]
vartype = elem.find("{https://github.com/ChimeraTK/ApplicationCore}value_type").text
vardirection = elem.find("{https://github.com/ChimeraTK/ApplicationCore}direction").text
varunit = elem.find("{https://github.com/ChimeraTK/ApplicationCore}unit").text
vardescription = elem.find("{https://github.com/ChimeraTK/ApplicationCore}description").text
if not vardescription :
vardescription = ""
varlength = int(elem.find("{https://github.com/ChimeraTK/ApplicationCore}numberOfElements").text)
if vardirection == "control_system_to_application" :
thetype=vartype+" (ro)"
else :
thetype=vartype
if varlength > 1 :
thetype=thetype+" ("+str(varlength)+" elements)"
print("| "+varname+" | "+vartype+" | "+thetype+" | "+vardescription[stripDescriptionPrefix:]+" |")
for elem in directory.findall("{https://github.com/ChimeraTK/ApplicationCore}directory") :
dirdescription = ""
for subelem in elem.findall("{https://github.com/ChimeraTK/ApplicationCore}variable") :
vardescription = subelem.find("{https://github.com/ChimeraTK/ApplicationCore}description").text
if not vardescription :
vardescription = ""
if dirdescription == "" :
dirdescription = vardescription
else :
dirdescription = findCommonPrefix(dirdescription, vardescription)
print("^ "+cwd+"/"+elem.attrib["name"]+" - "+dirdescription[:-2]+" ||||")
parseDirectory(elem, cwd+"/"+elem.attrib["name"], len(dirdescription)+1)
print("^ PV name ^ Type ^ Unit ^ Description ^")
tree = ET.parse("llrfctrl.xml")
root = tree.getroot()
parseDirectory(root,"",0)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment