Commit 5e662b55 authored by Ben Boeckel's avatar Ben Boeckel

MinimalBuildTools: remove old code

These generators are not tested and are unlikely to work with the new
module system.
parent aea4206d
import sys
import re
#---------------------------------------------------------------------------
def getUniqueClasses(inFile):
inFileHandle = open(sys.argv[1], 'r')
inFileContents = inFileHandle.read()
inFileHandle.close()
# look in file for this pattern: {vtkSomeClass}
rePattern = re.compile('{(vtk\S*).*}')
matchList = rePattern.findall(inFileContents)
classNames = []
for match in matchList:
classNames.append(match)
return sortAndRemoveDuplicates(classNames)
#---------------------------------------------------------------------------
def sortAndRemoveDuplicates(stringList):
d = dict() # using dict instead of set
for s in stringList: d[s] = None
uniqueList = d.keys()
uniqueList.sort()
return uniqueList
#---------------------------------------------------------------------------
def writeStrings(stringList, outFile):
"""Writes a list of strings to a file, writing one string per line"""
fd = open(outFile, 'w')
for string in stringList:
fd.write(string)
fd.write("\n")
#---------------------------------------------------------------------------
def printStrings(stringList):
for string in stringList: print string
#---------------------------------------------------------------------------
def main(argv=None):
if not argv: argv = sys.argv
if len(argv) != 3:
print "Usage: python ParseCSLog.py <log-file> <out-file>"
sys.exit(1)
classList = getUniqueClasses(argv[1])
writeStrings(classList, argv[2])
#---------------------------------------------------------------------------
if __name__ == "__main__":
main()
import os
import os.path
import sys
import xml.sax.handler
import xml.sax
#---------------------------------------------------------------------------
class ClassExtractor(xml.sax.handler.ContentHandler):
"""This class is essentially a callback. It is used to parse the xml files.
It searches for "class" attribute and collects it in a 'classes' array"""
def __init__(self):
self.classes = []
def startElement(self, name, attributes):
if attributes.has_key("class"):
self.classes.append(attributes["class"])
#---------------------------------------------------------------------------
def parseAndGetUniqueClasses(filesList):
"""Given a list of XML files, parses the files to get a list of
unique vtk class names for all vtk class names"""
parser = xml.sax.make_parser()
handler= ClassExtractor()
parser.setContentHandler(handler)
classNames = []
for item in filesList:
parser.parse(item)
for className in handler.classes:
if len(className) and className != "not-used":
classNames.append(className)
return sortAndRemoveDuplicates(classNames)
#---------------------------------------------------------------------------
def sortAndRemoveDuplicates(stringList):
d = dict() # using dict instead of set
for s in stringList: d[s] = None
uniqueList = d.keys()
uniqueList.sort()
return uniqueList
#---------------------------------------------------------------------------
def writeStrings(stringList, outFile):
"""Writes a list of strings to a file, writing one string per line"""
fd = open(outFile, 'w')
for string in stringList:
fd.write(string)
fd.write("\n")
#---------------------------------------------------------------------------
def printStrings(stringList):
for string in stringList: print string
#---------------------------------------------------------------------------
def main(argv=None):
if not argv: argv = sys.argv
if len(argv) < 3:
print "Usage: python ParseXMLResources.py <Output-File-Name> <List-Of-XML-Files>"
sys.exit(1)
classList = parseAndGetUniqueClasses(argv[2:])
writeStrings(classList, argv[1])
#---------------------------------------------------------------------------
if __name__ == "__main__":
main()
import sys
#---------------------------------------------------------------------------
def outputExternDefinitions(f, classList):
for className in classList:
f.write("extern void " + className + "_Init(vtkClientServerInterpreter* csi);\n")
f.write("\n")
#---------------------------------------------------------------------------
def outputInitializeFunction(f, classList, outputFile):
f.write(
"//-------------------------------------------------------------------------\n"
"/*\n"
" * This function initializes the classes to be used by the interpreter.\n"
" *\n"
" * @param csi client server interpreter reference\n"
" */\n"
"extern \"C\" void VTK_WRAP_CS_EXPORT vtkParaviewMinInit_Initialize(\n"
" vtkClientServerInterpreter *csi)\n"
"{\n"
)
for className in classList:
f.write(" " + className + "_Init(csi);\n")
f.write("}\n")
#---------------------------------------------------------------------------
def outputParaviewInitFile(classList, outputFile):
f = open(outputFile, 'w')
f.write(
"//-------------------------------------------------------------------------\n"
"/*\n"
"* @file vtkParaviewMinInit.cxx\n"
"*\n"
"* @brief This file is autogenerated from WriteMinInit.py\n"
"*/\n"
"//-------------------------------------------------------------------------\n"
"\n"
"#include \"vtkClientServerInterpreter.h\"\n"
"\n"
"#ifndef PARAVIEW_BUILD_SHARED_LIBS\n"
"/* #undef PARAVIEW_BUILD_SHARED_LIBS */\n"
"#endif\n"
"#if defined(PARAVIEW_BUILD_SHARED_LIBS) && defined(_WIN32)\n"
"# define VTK_WRAP_CS_EXPORT __declspec(dllexport)\n"
"#else\n"
"# define VTK_WRAP_CS_EXPORT\n"
"#endif\n\n"
)
outputExternDefinitions(f, classList)
outputInitializeFunction(f, classList, outputFile)
#---------------------------------------------------------------------------
def main(argv=None):
if not argv: argv = sys.argv
if len(argv) != 3:
print "Usage: python WriteMinInit.py <class-list-file> <output-file>"
sys.exit(1)
classes = list()
inFile = open(argv[1], 'r')
for line in inFile: classes.append(line.strip())
outputParaviewInitFile(classes, argv[2])
#---------------------------------------------------------------------------
if __name__ == "__main__":
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment