def filter_datastore_query(self, query):
    """Add query filter to restrict to this key range.

    Args:
      query: A datastore.Query instance.

    Returns:
      The input query restricted to this key range.
    """
    assert isinstance(query, datastore.Query)
    if self._app:
      query.__app = self._app
    if self.include_start:
      start_comparator = ">="
    else:
      start_comparator = ">"
    if self.include_end:
      end_comparator = "<="
    else:
      end_comparator = "<"
    if self.key_start:
      query.update({"__key__ %s" % start_comparator: self.key_start})
    if self.key_end:
      query.update({"__key__ %s" % end_comparator: self.key_end})
    return query
Add query filter to restrict to this key range.

    Args:
      query: A datastore.Query instance.

    Returns:
      The input query restricted to this key range.
    
mapreduce/lib/key_range/__init__.py