Anonymous committed 48154c2

move bnode hack into virtuoso repo
... debugging information in fresnel
... prevent loops in bnc method on graph

Comments (0)

Files changed (3)

         arguments are passed to the constructor for the new graph.
         result = Graph(*av, **kw)
+        log = __import__("logging").getLogger(__name__)
         for s,p,o in self.triples(triple):
-            if isinstance(o, BNode):
+            if isinstance(o, BNode) and (o, None, None) not in result:
                 result += self.bnc((o, None, None))
         return result
 __all__ = ["BNode", "Identifier", "Literal", "Node", "URIRef", "Variable"]
-    from rdflib.term import BNode as _BNode, Identifier, Literal, Node, URIRef, Variable
+    from rdflib.term import BNode, Identifier, Literal, Node, URIRef, Variable
 except ImportError:
-    from rdflib import URIRef, BNode as _BNode, Literal, Variable
+    from rdflib import URIRef, BNode, Literal, Variable
     from rdflib.Identifier import Identifier
     from rdflib.Node import Node
-from time import time
-from random import choice, seed
-from string import ascii_letters, digits
-class BNode(_BNode):
-    def __new__(cls, value=None, *av, **kw):
-        if value is None:
-            value = choice(ascii_letters) + \
-                "".join(choice(ascii_letters+digits) for x in range(7))
-        return _BNode(value, *av, **kw)


 from ordf.term import Literal, URIRef, BNode
 from datetime import datetime
+log = __import__("logging").getLogger(__name__)
 class Lens(Graph):
             hideProperties = Collection(self, hideProperties)
             hideProperties = list(hideProperties)
         subProperties = []
         for prop in properties:
             if isinstance(prop, BNode) and, RDF["type"], FRESNEL["PropertyDescription"])):
         elem = ET.Element("div")
         css = ["fresnel_resource"]
+        log.debug("    Resource: %s" % resource)
         if isinstance(resource, URIRef):
             uri = ET.Element("div")
             uri.set("class", "fresnel_resource_uri")
         return self.stylesheets, elem
     def formatProperty(self, graph, lens, format, resource, property):
+        log.debug("      Property: %s" % property)
+        log.debug("      Format: %s" % format)
         elem = ET.Element("div")
         css, styles = format.propertyStyles
         self._compiled = True
         for l in self.distinct_subjects(RDF["type"], FRESNEL["Lens"]):
+            log.debug("Compile: %s" % l)
             lens = Lens(fresnel=self, identifier=l) 
             lens += self.bnc((l, None, None))
             self.lenses[l] = lens
+            log.debug("XXX\n%s" % lens.serialize(format="n3"))
             for cls in lens.objects(l, FRESNEL["classLensDomain"]):
                 self.classLenses[cls] = lens
             for cls in lens.objects(l, FRESNEL["instanceLensDomain"]):
         else: lenses = self.lenses
         for lens_uri in lenses:
+            log.debug("Lens: %s" % lens_uri)
             lens = self.lenses.get(lens_uri)
             if lens is None:
             for typ in lens.distinct_objects(lens.identifier, FRESNEL["classLensDomain"]):
+                log.debug("    Type: %s" % typ)
                 resources = list(graph.distinct_subjects(RDF["type"], typ))
                 for resource in resources: