[4suite-checkins] In 4Suite/Ft/Rdf, files Triclops.py
CVS Server
cvs at 4suite.org
Sat May 24 07:56:40 MDT 2003
CVS activity for Chimezie Ogbuji <cogbuji at 4suite.org>
Update of /var/local/cvsroot/4Suite/Ft/Rdf
In directory dollar:/tmp/cvs-serv2082/Ft/Rdf
Modified Files:
Triclops.py
Log Message:
Updates to Triclops to get it back up and functional again. A few other additions.
Triclops is now Namespace aware in all of its queries. So things like
rdfs:Class can be entered (instead of fully qualified uris) provided
the mapping is in /ftss/dashboard/NsMappings.xml. frdf:versa-query now also looks in /ftss/dashboard/NsMappings.xml
for namespace mappings (since Triclops provides a nice interface for adding more mappings)
ViewCVS diff:
http://cvs.4suite.org/viewcvs/4Suite/Ft/Rdf/Triclops.py.diff?r1=1.26&r2=1.27
ViewCVS view:
http://cvs.4suite.org/viewcvs/4Suite/Ft/Rdf/Triclops.py?rev=1.27&content-type=text/vnd.viewcvs-markup
Index: Triclops.py
===================================================================
RCS file: /var/local/cvsroot/4Suite/Ft/Rdf/Triclops.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -U2 -r1.26 -r1.27
--- Triclops.py 22 Mar 2003 17:38:29 -0000 1.26
+++ Triclops.py 24 May 2003 13:56:40 -0000 1.27
@@ -1,275 +1,293 @@
-#!/usr/local/bin/python
-from string import split, replace, find, strip, join
-import urllib
-import os, re, sys, codecs
-from Ft.Rdf import RDF_SCHEMA_BASE, OBJECT_TYPE_RESOURCE
-from Ft.Xml import XPath
-
-
-def ParseNsMappings(nsMappings, nsDict={}, mappingUri=None):
- if type(nsMappings) == type('') or type(nsMappings) == type(u''):
- #parsing from text
- from Ft.Xml.Domlette import NonvalidatingReader
- mappingsNode = NonvalidatingReader.parseString(nsMappings.encode('utf-8'), mappingUri)
- elif nsMappings:
- #parsing from node
- mappingsNode = nsMappings
- else:
- return {}
-
- mappingsContext = XPath.Context.Context(mappingsNode, processorNss=nsDict)
-
- _mappingExpr = XPath.Compile('//fres:NsMapping')
- _mappingPrefixExpression = XPath.Compile('string(Prefix)')
- _mappingUriExpression = XPath.Compile('string(Uri)')
-
-
- mappings={}
- for nsMapping in _mappingExpr.evaluate(mappingsContext):
- mappingsContext.node = nsMapping
- prefix=_mappingPrefixExpression.evaluate(mappingsContext)
- uri =_mappingUriExpression.evaluate(mappingsContext)
- print "parsed out %s -> %s from user ns mapping"%(prefix,uri)
- mappings[prefix]=uri
-
- return mappings
-
-class RDFGraphVizEngine:
- def __init__(self, tempDir, gvisDir, mapName='rdfImageMap',
- uriFormat='%s', maxArcs=300, outputJpeg=None):
- self.maxArcs = maxArcs
- self.mapName = mapName
- self.uriFormat = uriFormat
- self.gviz = strip(gvisDir)
- self.tmp = strip(tempDir)
- self.outputJpeg = outputJpeg or os.path.join(self.tmp, 'output.jpg')
- dotPath = os.path.join(self.gviz, 'dot')
- winDotPath = os.path.join(self.gviz, 'dot.exe')
- if not os.path.exists(dotPath) and not os.path.exists(winDotPath):
- raise Exception("graphViz is not properly setup or not installed (cannot locate 'dot' executable at %s or %s)"%(str(dotPath),str(winDotPath)))
- if not os.path.exists(tempDir):
- raise Exception("graphViz is not properly setup or not installed (temporary workspace provided doesn't not exist)")
-
- print "setting up RDFGraphVizEngine. Gvis dir is %s, uriFormat is %s, and tmp dir is at %s"%(self.gviz, self.uriFormat, self.tmp)
-
- def retrieveResourceUris(self, resultNode):
- resoureExpression = Compile('//Resource')
-
- def resourceExists(self, name, model):
- """
- Checks model.complete(model,None,None) to determine if name exists
- """
- try:
- stmts=model.complete(name, None, None)
- except:
- return []
- else:
- return stmts
-
- def resourceViewer(self, model, resourceUri=None, scope=0, rotate=0,
- splitpreds=1, resultTxt=None, nsDict=None):
- nsDict = nsDict or {}
- singleResource = ''
- if resultTxt:
- color = 'color=red'
- stmts = []
- from Ft.Xml.Domlette import NonvalidatingReader
- #FIXME: Find a better way to detect null results, perhaps from raw Versa data. Otherwise we should be passing through exceptions.
- try:
- resultsNode = NonvalidatingReader.parseString(
- resultTxt.encode('utf-8'), 'http://4Suite.org')
- except:
- return "No resources to view"
- resultsContext = XPath.Context.Context(resultsNode)
-
- _resourceExpr = XPath.Compile('//Resource/text()')
- evaluated = _resourceExpr.evaluate(resultsContext)
- if len(evaluated) == 1:
- singleResource = evaluated[0].nodeValue
- for res in evaluated:
- res = res.nodeValue
- #print "adding *all* statements about %s to graph"%(res)
- print "Adding statements about %s to graph"%(res)
- stmts_in_scope = model.complete('', '', '', scope=res)
- if stmts_in_scope:
- #To avoid duplicate statements in cases of rdf:about=""
- stmts.extend(model.complete('', '', '', scope=res))
- else:
- stmts.extend(model.complete(res, '', ''))
- stmts.extend(model.complete('', '', res))
- else:
- if resourceUri:
- singleResource = resourceUri
- if scope:
- color=''
- try:
- stmts = model.complete('', '', '', scope=resourceUri)
- except:
- stmts = []
- else:
- color = 'color=red'
- try:
- stmts = model.complete(resourceUri, '', '')
- except:
- stmts=[]
-
- try:
- stmts.extend(model.complete('', '', resourceUri))
- except:
- pass
- else:
- stmts=model.complete('', '', '')
-
- if rotate:
- output = 'digraph G {rotate=90\n'
- else:
- output = 'digraph G {\n'
- formatDict={}
-
- arcs = len(stmts)
- if arcs > self.maxArcs:
- raise "Attempt to process %s arcs. This is beyond the threshold of graphviz's capabilities and size constraints"%(arcs)
-
- for stmt in stmts:
- #print stmt.subject, stmt.predicate, stmt.object
- kv = [(stmt.predicate, stmt.object, stmt.objectType)]
- currentKv = formatDict.get(stmt.subject, [])
- formatDict[stmt.subject] = currentKv + kv
-
- index = 0
- unknownIndex = len(formatDict.keys())
- for resName, resourceArcs in formatDict.items():
- if resName == singleResource:
- if model.isBnodeLabel(resName):
- output = output+'\t%s [label = "%s",style=filled, fillcolor=yellow]\n'%(index, '')
- else:
- output = output+'\t%s [label = "%s",style=filled, fillcolor=yellow]\n'%(index, ResourceName(model, resName))
- elif model.isBnodeLabel(resName):
- output = output+'\t%s [label = "%s",URL="%s"]\n'%(index, '', self.uriFormat%(urllib.quote(resName)))
- else:
- output = output+'\t%s [label = "%s",URL="%s" %s]\n'%(index, ResourceName(model, resName), self.uriFormat%(urllib.quote(resName)), color)
- for predicate, object, otype in resourceArcs:
- objUri = object
- if splitpreds:
- predicate = splitPredicate(predicate, nsDict)
- if object in formatDict.keys():
- object = formatDict.keys().index(object)
- else:
- exists = self.resourceExists(object, model)
- #isLiteralbySchema = model.complete(predicate,'http://www.w3.org/TR/1999/PR-rdf-schema-19990303#range','http://www.w3.org/TR/1999/PR-rdf-schema-19990303#Literal') or model.complete(predicate,'http://www.w3.org/TR/1999/PR-rdf-schema-19990303#range','http://www.w3.org/TR/xmlschema-2/#string')
- #isLiteral = isLiteralbySchema or (not stmtsAbout)
- isResource = (otype == OBJECT_TYPE_RESOURCE)
- if isResource:
- resUri = object
- if exists:
- output = output + '\t%s [label = "%s",URL="%s" %s]\n'%(unknownIndex, ResourceName(model, objUri).replace('"', "'"), self.uriFormat%(urllib.quote(object)), color)
- else:
- output = output + '\t%s [label = "%s"]\n'%(unknownIndex, ResourceName(model, objUri).replace('"', "'"))
-
- else:
- output = output + '\t%s [label = "%s", shape=box]\n'%(unknownIndex, ResourceName(model, objUri).replace('"', "'"))
- object = unknownIndex
- unknownIndex += 1
-
- output = output + '\t%s -> %s [label = "%s"];\n'%(index, object, predicate)
- index = index + 1
-
- output = output + "}"
-
- outputDot = os.path.join(self.tmp, 'output.dot')
- dotExecPath = os.path.join(self.gviz, 'dot')
- outputMap = os.path.join(self.tmp, 'output.map')
- codecs.open(outputDot, 'w', 'utf-8').write(output)
-
- # dot -Tismap output.dot -o output.map
- args = [os.path.basename(dotExecPath), '-Tismap', outputDot,
- '-o', outputMap]
- os.spawnv(os.P_WAIT, dotExecPath, args)
-
- # dot -Tjpeg output.dot -o output.jpg
- args = [os.path.basename(dotExecPath), '-Tjpeg', outputDot,
- '-o', self.outputJpeg]
- os.spawnv(os.P_WAIT, dotExecPath, args)
-
- print "Graphviz generation complete (image map and image)"
-
- matches = re.compile(r'rectangle\s+\([\d]+,[\d]+\)\s+\([\d]+,[\d]+\)\s+[^\s]+.*').findall(codecs.open(outputMap, 'r', 'utf-8').read() )
- rt = '<MAP name="%s">\n'%(self.mapName)
- for match in matches:
- splitString = match.split(' ')
- corner1x, corner1y = split(splitString[1][1:-1], ',')
- corner2x, corner2y = split(splitString[2][1:-1], ',')
- resourceUri=splitString[3]
- rt=rt+'<AREA href="%s" shape="rect" coords="%s,%s,%s,%s"/>\n'%(resourceUri, corner1x, corner2y, corner2x, corner1y)
- rt=rt+'</MAP>'
- if scope:
- rt=''
- return rt
-
-def splitPredicate(predicate,nsDict):
-
- reverseDict={}
- for key, value in nsDict.items():
- reverseDict[value]=key
-
- splitPred=predicate.split('#')
-
- if len(splitPred)>1:
- local = splitPred[-1]
- if len(splitPred)>2:
- uri = join(splitPred[0:-2],'#')
- else:
- uri = splitPred[0]
-
- uri = uri + '#'
- elif len(predicate.split('/'))>1:
- local = predicate.split('/')[-1]
- uri = join(predicate.split('/')[0:-2],'/') + '/'
- prefix = ''
-
- if reverseDict.has_key(uri):
- prefix = reverseDict[uri] + ':'
-
- return prefix + local
-
-def ResourceName(model, resourceUri):
- label_stmts = model.complete(resourceUri, RDF_SCHEMA_BASE+"label", None)
- if label_stmts:
- l = "<%s>"%label_stmts[0].object
- return l
- else: return resourceUri.replace('\n','\\n')
-
-
-if __name__ == '__main__':
-
- from Ft.Rdf import Model
- from Ft.Rdf.Drivers import Memory
- from Ft.Rdf.Serializers.Dom import Serializer
- from Ft.Xml.Domlette import NonvalidatingReader
-
- if len(sys.argv)<5:
- print "usage: RDFVisualizer.py tempdirectory graphVizBinDir rdfModel output\n"
- print "tempdirectory - a directory to use as temporary workspace"
- print "graphVizBinDir - the 'bin' directory of graphvis"
- print "rdfModel - the file containing the RDF serialization to graph"
- print "output - the name of the file to write the jpeg image to"
- sys.exit(0)
-
- tmpDir = sys.argv[1]
- gvisBin = sys.argv[2]
- modelFile = sys.argv[3]
- output = sys.argv[4]
-
- print "%s -> %s"%(modelFile, output)
-
- doc = NonvalidatingReader.parseUri(urllib.pathname2url(modelFile))
-
- d = Memory.DbAdapter('')
- d.begin()
- model = Model.Model(d)
- szr = Serializer()
- szr.deserialize(model, doc, 'versaExample')
- gvizAgent=RDFGraphVizEngine(tempDir=tmpDir, gvisDir=gvisBin,
- outputJpeg=output)
- gvizAgent.resourceViewer(model, scope=1)
-
+#!/usr/local/bin/python
+from string import split, replace, find, strip, join
+import urllib
+import os, re, sys, codecs
+from Ft.Rdf import RDF_SCHEMA_BASE, OBJECT_TYPE_RESOURCE
+from Ft.Xml import XPath
+from Ft.Server import SCHEMA_NSS, RESERVED_NAMESPACE
+from Ft.Server.Common.Schema import g_rdfResourceTypes, TYPE
+from Ft.Server.Common.ResourceTypes import ResourceType
+from Ft.Lib.Uri import FTSS_URI_SCHEME
+
+
+def ParseNsMappings(nsMappings, nsDict={}, mappingUri=None):
+
+ if type(nsMappings) == type('') or type(nsMappings) == type(u''):
+ #parsing from text
+ from Ft.Xml.Domlette import NonvalidatingReader
+ mappingsNode = NonvalidatingReader.parseString(nsMappings.encode('utf-8'), mappingUri)
+ elif nsMappings:
+ #parsing from node
+ mappingsNode = nsMappings
+ else:
+ return {}
+
+ nsDict['fres']=RESERVED_NAMESPACE
+ mappingsContext = XPath.Context.Context(mappingsNode, processorNss=nsDict)
+
+ _mappingExpr = XPath.Compile('//fres:NsMapping')
+ _mappingPrefixExpression = XPath.Compile('string(Prefix)')
+ _mappingUriExpression = XPath.Compile('string(Uri)')
+
+
+ mappings={}
+ for nsMapping in _mappingExpr.evaluate(mappingsContext):
+ mappingsContext.node = nsMapping
+ prefix=_mappingPrefixExpression.evaluate(mappingsContext)
+ uri =_mappingUriExpression.evaluate(mappingsContext)
+ print "parsed out %s -> %s from user ns mapping"%(prefix,uri)
+ mappings[prefix]=uri
+
+ return mappings
+
+class RDFGraphVizEngine:
+ def __init__(self, tempDir, gvisDir, mapName='rdfImageMap',
+ uriFormat='%s', maxArcs=300, outputJpeg=None):
+ self.maxArcs = maxArcs
+ self.mapName = mapName
+ self.uriFormat = uriFormat
+ self.gviz = strip(gvisDir)
+ self.tmp = strip(tempDir)
+ self.outputJpeg = outputJpeg or os.path.join(self.tmp, 'output.jpg')
+ dotPath = os.path.join(self.gviz, 'dot')
+ winDotPath = os.path.join(self.gviz, 'dot.exe')
+ if not os.path.exists(dotPath) and not os.path.exists(winDotPath):
+ raise Exception("graphViz is not properly setup or not installed (cannot locate 'dot' executable at %s or %s)"%(str(dotPath),str(winDotPath)))
+ if not os.path.exists(tempDir):
+ raise Exception("graphViz is not properly setup or not installed (temporary workspace provided doesn't not exist)")
+
+ print "setting up RDFGraphVizEngine. Gvis dir is %s, uriFormat is %s, and tmp dir is at %s"%(self.gviz, self.uriFormat, self.tmp)
+
+ def retrieveResourceUris(self, resultNode):
+ resoureExpression = Compile('//Resource')
+
+ def resourceExists(self, name, model):
+ """
+ Checks model.complete(model,None,None) to determine if name exists
+ """
+ try:
+ stmts=model.complete(name, None, None)
+ except:
+ return []
+ else:
+ return stmts
+
+ def resourceViewer(self, model, resourceUri=None, scoped=0, rotate=0,
+ splitpreds=1, resultTxt=None, nsDict=None):
+ nsDict = nsDict or {}
+ singleResource = ''
+ if resultTxt:
+ color = 'color=red'
+ stmts = []
+ from Ft.Xml.Domlette import NonvalidatingReader
+ #FIXME: Find a better way to detect null results, perhaps from raw Versa data. Otherwise we should be passing through exceptions.
+ try:
+ resultsNode = NonvalidatingReader.parseString(
+ resultTxt.encode('utf-8'), 'http://4Suite.org')
+ except:
+ return "No resources to view"
+ resultsContext = XPath.Context.Context(resultsNode)
+
+ _resourceExpr = XPath.Compile('//Resource/text()')
+ evaluated = _resourceExpr.evaluate(resultsContext)
+ if len(evaluated) == 1:
+ singleResource = evaluated[0].nodeValue
+ for res in evaluated:
+ res = res.nodeValue
+ if len(split(res,'ftss:///')) > 1:
+ res = '/'+split(res,'ftss:///')[-1]
+ #print "adding *all* statements about %s to graph"%(res)
+ print "Adding statements about %s to graph"%(res)
+
+
+ #FIXME: if res is an rdf document and scoped = 1, then
+ #use ftss:/// form for model scope
+ if model.containsPattern(res,TYPE,g_rdfResourceTypes[ResourceType.RDF_DOCUMENT]):
+ print "Rendering RDF document %s as scoped subgraph"%(FTSS_URI_SCHEME+'://'+res)
+ stmts_in_scope = model.complete('', '', '', scope=FTSS_URI_SCHEME+'://'+res)
+ else:
+ stmts_in_scope = model.complete('', '', '', scope=res)
+ if stmts_in_scope and scoped:
+ #To avoid duplicate statements in cases of rdf:about=""
+ stmts.extend(stmts_in_scope)
+ else:
+ stmts.extend(model.complete(res, '', ''))
+ stmts.extend(model.complete('', '', res))
+ else:
+ if resourceUri:
+ singleResource = resourceUri
+ if scoped:
+ color=''
+ try:
+ stmts = model.complete('', '', '', scope=resourceUri)
+ except:
+ stmts = []
+ else:
+ color = 'color=red'
+ try:
+ stmts = model.complete(resourceUri, '', '')
+ except:
+ stmts=[]
+
+ try:
+ stmts.extend(model.complete('', '', resourceUri))
+ except:
+ pass
+ else:
+ stmts=model.complete('', '', '')
+
+ if rotate:
+ output = 'digraph G {rotate=90\n'
+ else:
+ output = 'digraph G {\n'
+ formatDict={}
+
+ arcs = len(stmts)
+ if arcs > self.maxArcs:
+ raise "Attempt to process %s arcs. This is beyond the threshold of graphviz's capabilities and size constraints"%(arcs)
+
+ for stmt in stmts:
+ #if the arc is from container to child metadata, change object to fully qualified name
+ if not split(stmt.predicate,'container.child')[-1]:
+ strippedObject = split(stmt.object,';metadata')[0]
+ if stmt.subject[-1] == '/':
+ ob = stmt.subject + strippedObject
+ else: ob = stmt.subject + '/' + strippedObject
+ kv = [(stmt.predicate, ob, stmt.objectType)]
+ else: kv = [(stmt.predicate, stmt.object, stmt.objectType)]
+ currentKv = formatDict.get(stmt.subject, [])
+ formatDict[stmt.subject] = currentKv + kv
+
+ index = 0
+ unknownIndex = len(formatDict.keys())
+ for resName, resourceArcs in formatDict.items():
+ if resName == singleResource:
+ if model.isBnodeLabel(resName):
+ output = output+'\t%s [label = "%s",style=filled, fillcolor=yellow]\n'%(index, '')
+ else:
+ output = output+'\t%s [label = "%s",style=filled, fillcolor=yellow]\n'%(index, ResourceName(model, resName))
+ elif model.isBnodeLabel(resName):
+ output = output+'\t%s [label = "%s",URL="%s"]\n'%(index, '', self.uriFormat%(urllib.quote(resName)))
+ else:
+ output = output+'\t%s [label = "%s",URL="%s" %s]\n'%(index, ResourceName(model, resName), self.uriFormat%(urllib.quote(resName)), color)
+ for predicate, object, otype in resourceArcs:
+ objUri = object
+ if splitpreds:
+ predicate = splitPredicate(predicate, nsDict)
+ if object in formatDict.keys():
+ object = formatDict.keys().index(object)
+ else:
+ exists = self.resourceExists(object, model)
+ #isLiteralbySchema = model.complete(predicate,'http://www.w3.org/TR/1999/PR-rdf-schema-19990303#range','http://www.w3.org/TR/1999/PR-rdf-schema-19990303#Literal') or model.complete(predicate,'http://www.w3.org/TR/1999/PR-rdf-schema-19990303#range','http://www.w3.org/TR/xmlschema-2/#string')
+ #isLiteral = isLiteralbySchema or (not stmtsAbout)
+ isResource = (otype == OBJECT_TYPE_RESOURCE)
+ if isResource:
+ resUri = object
+ if exists:
+ output = output + '\t%s [label = "%s",URL="%s" %s]\n'%(unknownIndex, ResourceName(model, objUri).replace('"', "'"), self.uriFormat%(urllib.quote(object)), color)
+ else:
+ output = output + '\t%s [label = "%s"]\n'%(unknownIndex, ResourceName(model, objUri).replace('"', "'"))
+
+ else:
+ output = output + '\t%s [label = "%s", shape=box]\n'%(unknownIndex, ResourceName(model, objUri).replace('"', "'"))
+ object = unknownIndex
+ unknownIndex += 1
+
+ output = output + '\t%s -> %s [label = "%s"];\n'%(index, object, predicate)
+ index = index + 1
+
+ output = output + "}"
+
+ outputDot = os.path.join(self.tmp, 'output.dot')
+ dotExecPath = os.path.join(self.gviz, 'dot')
+ outputMap = os.path.join(self.tmp, 'output.map')
+ codecs.open(outputDot, 'w', 'utf-8').write(output)
+
+ # dot -Tismap output.dot -o output.map
+ args = [os.path.basename(dotExecPath), '-Tismap', outputDot,
+ '-o', outputMap]
+ os.spawnv(os.P_WAIT, dotExecPath, args)
+
+ # dot -Tjpeg output.dot -o output.jpg
+ args = [os.path.basename(dotExecPath), '-Tjpeg', outputDot,
+ '-o', self.outputJpeg]
+ os.spawnv(os.P_WAIT, dotExecPath, args)
+
+ matches = re.compile(r'rectangle\s+\([\d]+,[\d]+\)\s+\([\d]+,[\d]+\)\s+[^\s]+.*').findall(codecs.open(outputMap, 'r', 'utf-8').read() )
+ rt = '<MAP name="%s">\n'%(self.mapName)
+ for match in matches:
+ splitString = match.split(' ')
+ corner1x, corner1y = split(splitString[1][1:-1], ',')
+ corner2x, corner2y = split(splitString[2][1:-1], ',')
+ resourceUri=splitString[3]
+ rt=rt+'<AREA href="%s" shape="rect" coords="%s,%s,%s,%s"/>\n'%(resourceUri, corner1x, corner2y, corner2x, corner1y)
+ rt=rt+'</MAP>'
+ return rt
+
+def splitPredicate(predicate,nsDict):
+
+ reverseDict={}
+ for key, value in nsDict.items():
+ reverseDict[value]=key
+
+ splitPred=predicate.split('#')
+
+ if len(splitPred)>1:
+ local = splitPred[-1]
+ if len(splitPred)>2:
+ uri = join(splitPred[0:-2],'#')
+ else:
+ uri = splitPred[0]
+
+ uri = uri + '#'
+ elif len(predicate.split('/'))>1:
+ local = predicate.split('/')[-1]
+ uri = join(predicate.split('/')[0:-2],'/') + '/'
+ prefix = ''
+
+ if reverseDict.has_key(uri):
+ prefix = reverseDict[uri] + ':'
+
+ return prefix + local
+
+def ResourceName(model, resourceUri):
+ label_stmts = model.complete(resourceUri, RDF_SCHEMA_BASE+"label", None)
+ if label_stmts:
+ l = "<%s>"%label_stmts[0].object
+ return l
+ else: return resourceUri.replace('\n','\\n')
+
+
+if __name__ == '__main__':
+
+ from Ft.Rdf import Model
+ from Ft.Rdf.Drivers import Memory
+ from Ft.Rdf.Serializers.Dom import Serializer
+ from Ft.Xml.Domlette import NonvalidatingReader
+
+ if len(sys.argv)<5:
+ print "usage: RDFVisualizer.py tempdirectory graphVizBinDir rdfModel output\n"
+ print "tempdirectory - a directory to use as temporary workspace"
+ print "graphVizBinDir - the 'bin' directory of graphvis"
+ print "rdfModel - the file containing the RDF serialization to graph"
+ print "output - the name of the file to write the jpeg image to"
+ sys.exit(0)
+
+ tmpDir = sys.argv[1]
+ gvisBin = sys.argv[2]
+ modelFile = sys.argv[3]
+ output = sys.argv[4]
+
+ print "%s -> %s"%(modelFile, output)
+
+ doc = NonvalidatingReader.parseUri(urllib.pathname2url(modelFile))
+
+ d = Memory.DbAdapter('')
+ d.begin()
+ model = Model.Model(d)
+ szr = Serializer()
+ szr.deserialize(model, doc, 'versaExample')
+ gvizAgent=RDFGraphVizEngine(tempDir=tmpDir, gvisDir=gvisBin,
+ outputJpeg=output)
+ gvizAgent.resourceViewer(model, scope=1)
+
More information about the 4suite-checkins
mailing list