in assets/lambda_helper_neptune/python/rdflib/plugins/stores/regexmatching.py [0:0]
def triples(self, triple, context=None):
(subject, predicate, object_) = triple
if isinstance(subject, REGEXTerm) or \
isinstance(predicate, REGEXTerm) or \
isinstance(object_, REGEXTerm) or \
(context is not None
and isinstance(context.identifier, REGEXTerm)):
# One or more of the terms is a REGEX expression, so we must
# replace it / them with wildcard(s) and match after we query.
s = not isinstance(subject, REGEXTerm) and subject or None
p = not isinstance(predicate, REGEXTerm) and predicate or None
o = not isinstance(object_, REGEXTerm) and object_ or None
c = (context is not None
and not isinstance(context.identifier, REGEXTerm)) \
and context \
or None
for (s1, p1, o1), cg in self.storage.triples((s, p, o), c):
matchingCtxs = []
for ctx in cg:
if c is None:
if context is None \
or context.identifier.compiledExpr.match(
ctx.identifier):
matchingCtxs.append(ctx)
else:
matchingCtxs.append(ctx)
if matchingCtxs \
and regexCompareQuad((s1, p1, o1, None),
(subject, predicate, object_, None)):
yield (s1, p1, o1), (c for c in matchingCtxs)
else:
for (s1, p1, o1), cg in self.storage.triples(
(subject, predicate, object_), context):
yield (s1, p1, o1), cg