Esempio n. 1
0
 def testJsonReadAndWriteSqg(self):
     for include in self.jsonFiles:
         logger.info("Going to use jsonRead to parse/write/parse SQG %s" % include)
         #First read
         file = os.path.join(getPysqgIncludeDir(), include + ".json")
         sqg = readJsonSqgFile(file)
         #Then write
         writeJsonSqgFile(sqg, self.tempFile)
         #Now parse again
         readJsonSqgFile(self.tempFile)
Esempio n. 2
0
"""Pretty prints the various sqg files in the include hierarchy
"""

import os
from pysqg.bioio import system
from pysqg.shared import getPysqgIncludeDir, getPysqgBaseDir

for file in os.listdir(getPysqgIncludeDir()):
    if ".json" in file:
        include = file[:-5]
        absFile = os.path.join(getPysqgIncludeDir(), file)
        outFile = os.path.join(getPysqgBaseDir(), "doc", "include", include + ".rst")
        outFileHandle = open(outFile, "w")
        outFileHandle.write("%s.sqg\n_________________________________\n\n>>>\n" % include)
        outFileHandle.close()
        system("cat %s | python -mjson.tool >> %s" % (absFile, outFile))
Esempio n. 3
0
inheritanceGraph = Sqg(includes=["mixedGraph"])
arrayLists = InMemoryArrayList(type="arrayLists", inherits="node", variables=[ "name", "string", "arrayNames", "string", "arrayTypes", "string" ]) #Nodes representing array list types
sqgs = InMemoryArrayList(type="sqgs", inherits="node", variables=[ "name", "string" ]) #Nodes representing sqg definitions
inheritEdges = InMemoryArrayList(type="inherit", inherits="directedEdge") #Edges showing inheritance between array lists
graphEdges = InMemoryArrayList(type="graph", inherits="directedEdge") #Edges showing which show which sqg defined which array list

#Add them to the graph
inheritanceGraph.setArrayList(arrayLists)
inheritanceGraph.setArrayList(sqgs)
inheritanceGraph.setArrayList(inheritEdges)
inheritanceGraph.setArrayList(graphEdges)

#Build the nodes and connect the graphs to the array types
typeStringsToNodeNamesAndArrays = {}
i = 0
for file in os.listdir(getPysqgIncludeDir()):
    if file[-5:] == ".json":
        Sqg(includes=[file[:-5]]) #This ensures the graphs are in memory
        graphNode = i
        i = i+1
        sqgs.addDict({ "nodeName":graphNode, "name":file[:-5] })
        #Now iterate through the new array list types
        fileHandle = open(os.path.join(getPysqgIncludeDir(), file), 'r')
        jsonSqg = json.load(fileHandle)
        fileHandle.close()
        for arrayListType in jsonSqg.keys(): 
            if arrayListType not in ("name", "include", "parents", "sharedVariables"): #This is very hacky, it would be nice to have a clean way to know which sqg defined which array list.
                arrayList = InMemoryArrayList(type=arrayListType)
                arrayNode = i
                i = i+1
                typeStringsToNodeNamesAndArrays[arrayListType] = (arrayNode, arrayList)
Esempio n. 4
0
 def testParseJsonFiles(self):
     for include in self.jsonFiles:
         logger.info("Going to parse %s" % include)
         fileHandle = open(os.path.join(getPysqgIncludeDir(), include + ".json"), 'r')
         json.load(fileHandle)
         fileHandle.close()
Esempio n. 5
0
def parseInclude(include):
    includeFile = os.path.join(getPysqgIncludeDir(), include + ".json")
    logger.debug("Going to parse the include file: %s", includeFile)
    from pysqg.jsonSqg import readJsonSqgFile
    return readJsonSqgFile(includeFile)