Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
    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))
Exemplo n.º 6
0
    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))