def predicate_object_list(self, predicate_object_list): for i, (predicate, object_list) in enumerate(predicate_object_list): if i: yield ';' yield self.expression(predicate) for j, object in enumerate(to_list(object_list)): if j: yield ',' yield self.expression(object)
def __init__(self, projection, pattern=None, order_by=None, limit=None, offset=None): super(ProjectionSupportingQuery, self).__init__(pattern, order_by=order_by, limit=limit, offset=offset) if projection != '*': projection = map(to_variable, to_list(projection)) self.projection = tuple(projection)
def project(self, *terms, **kwargs): """ Return a new `Select` with the given terms projected in the SELECT clause. Each argument may be a variable or a sequence of variables, and each variable is converted to a `rdflib.Variable` instance using `to_variable` (which means variables may also be specified as strings and `Expression` instances). If the keyword-only argument `append` is true, the specified variables will be appended to the current projection instead of replacing it. """ append = kwargs.pop('append', False) projection = append and list(self.projection) or [] for arg in terms: for variable in map(to_variable, to_list(arg)): projection.append(variable) return self._clone(projection=tuple(projection))