def query_Ask(subject, contexts): """ Construct :class:`surf.query.Query` of type **ASK**. """ query = ask().where((subject, '?p', '?o')) if contexts: query.from_(*contexts) query.from_named(*contexts) return query
def query_Ask(subject, context): """ Construct :class:`surf.query.Query` of type **ASK**. """ query = ask() if context: pattern = named_group(context, (subject, '?p', '?o')) query.where(pattern) else: query.where((subject, '?p', '?o')) return query
def test_ask(self): """ Try ASK. """ expected = canonical(u""" ASK FROM <http://uri1> { ?s ?p ?o } """) query = ask().from_(URIRef("http://uri1")).where(("?s", "?p", "?o")) result = canonical(SparqlTranslator(query).translate()) self.assertEqual(expected, result)
def query_ask(s, context): """ Construct :class:`surf.query.Query` of type **ASK**. :param s: the `subject` :param context: the context :return: the query :rtype: :class:`surf.query.Query` """ query = ask() if context: pattern = named_group(context, (s, '?p', '?o')) query.where(pattern) else: query.where((s, '?p', '?o')) return query