view rdfdb/syncedgraph/readonly_graph.py @ 94:8bc63c7b619b

mv syncedgraph to subdir
author drewp@bigasterisk.com
date Sat, 21 May 2022 22:15:14 -0700
parents rdfdb/readonly_graph.py@219d9e89b15c
children
line wrap: on
line source

class ReadOnlyConjunctiveGraph(object):
    """similar to rdflib's ReadOnlyGraphAggregate but takes one CJ in, instead
    of a bunch of Graphs"""

    def __init__(self, graph):
        self.graph = graph

    def __getattr__(self, attr):
        if attr in ['subjects', 'value', 'objects', 'triples', 'label']:  # not complete
            return getattr(self.graph, attr)
        raise TypeError("can't access %r of read-only graph" % attr)

    def __len__(self):
        return len(self.graph)

    def contextsForStatement(self, stmt):
        raise NotImplementedError