Add missing 'versionadded' directives, minor cleanup

This commit is contained in:
Tyler Hobbs
2014-05-28 14:32:05 -05:00
parent d1ae7c6f1d
commit 3e28e270d7
5 changed files with 36 additions and 11 deletions

View File

@@ -1002,7 +1002,7 @@ class Session(object):
:meth:`.ResponseFuture.add_errback`; even if a query exceeds this default :meth:`.ResponseFuture.add_errback`; even if a query exceeds this default
timeout, neither the registered callback or errback will be called. timeout, neither the registered callback or errback will be called.
.. versionadded:: 2.0.0b1 .. versionadded:: 2.0.0
""" """
default_consistency_level = ConsistencyLevel.ONE default_consistency_level = ConsistencyLevel.ONE
@@ -1032,7 +1032,7 @@ class Session(object):
This only takes effect when protocol version 2 or higher is used. This only takes effect when protocol version 2 or higher is used.
See :attr:`.Cluster.protocol_version` for details. See :attr:`.Cluster.protocol_version` for details.
.. versionadded:: 2.0.0b1 .. versionadded:: 2.0.0
""" """
_lock = None _lock = None
@@ -2152,6 +2152,8 @@ class ResponseFuture(object):
Returns :const:`True` if there are more pages left in the Returns :const:`True` if there are more pages left in the
query results, :const:`False` otherwise. This should only query results, :const:`False` otherwise. This should only
be checked after the first page has been returned. be checked after the first page has been returned.
.. versionadded:: 2.0.0
""" """
return self._paging_state is not None return self._paging_state is not None
@@ -2162,6 +2164,8 @@ class ResponseFuture(object):
is raised. Also see :attr:`.has_more_pages`. is raised. Also see :attr:`.has_more_pages`.
This should only be called after the first page has been returned. This should only be called after the first page has been returned.
.. versionadded:: 2.0.0
""" """
if not self._paging_state: if not self._paging_state:
raise QueryExhausted() raise QueryExhausted()
@@ -2582,6 +2586,8 @@ class QueryExhausted(Exception):
Raised when :meth:`.ResponseFuture.start_fetching_next_page()` is called and Raised when :meth:`.ResponseFuture.start_fetching_next_page()` is called and
there are no more pages. You can check :attr:`.ResponseFuture.has_more_pages` there are no more pages. You can check :attr:`.ResponseFuture.has_more_pages`
before calling to avoid this. before calling to avoid this.
.. versionadded:: 2.0.0
""" """
pass pass
@@ -2605,7 +2611,7 @@ class PagedResult(object):
an :class:`Exception` to be raised while fetching the next page, just an :class:`Exception` to be raised while fetching the next page, just
like you might see on a normal call to ``session.execute()``. like you might see on a normal call to ``session.execute()``.
.. versionadded: 2.0.0b1 .. versionadded: 2.0.0
""" """
def __init__(self, response_future, initial_response): def __init__(self, response_future, initial_response):

View File

@@ -63,6 +63,9 @@ def tuple_factory(colnames, rows):
>>> rows = session.execute("SELECT name, age FROM users LIMIT 1") >>> rows = session.execute("SELECT name, age FROM users LIMIT 1")
>>> print rows[0] >>> print rows[0]
('Bob', 42) ('Bob', 42)
.. versionchanged:: 2.0.0
moved from ``cassandra.decoder`` to ``cassandra.query``
""" """
return rows return rows
@@ -92,6 +95,9 @@ def named_tuple_factory(colnames, rows):
>>> age = user[1] >>> age = user[1]
>>> print "name: %s, age: %d" % (name, age) >>> print "name: %s, age: %d" % (name, age)
name: Bob, age: 42 name: Bob, age: 42
.. versionchanged:: 2.0.0
moved from ``cassandra.decoder`` to ``cassandra.query``
""" """
Row = namedtuple('Row', map(_clean_column_name, colnames)) Row = namedtuple('Row', map(_clean_column_name, colnames))
return [Row(*row) for row in rows] return [Row(*row) for row in rows]
@@ -110,6 +116,8 @@ def dict_factory(colnames, rows):
>>> print rows[0] >>> print rows[0]
{'age': 42, 'name': 'Bob'} {'age': 42, 'name': 'Bob'}
.. versionchanged:: 2.0.0
moved from ``cassandra.decoder`` to ``cassandra.query``
""" """
return [dict(zip(colnames, row)) for row in rows] return [dict(zip(colnames, row)) for row in rows]
@@ -118,6 +126,9 @@ def ordered_dict_factory(colnames, rows):
""" """
Like :meth:`~cassandra.query.dict_factory`, but returns each row as an OrderedDict, Like :meth:`~cassandra.query.dict_factory`, but returns each row as an OrderedDict,
so the order of the columns is preserved. so the order of the columns is preserved.
.. versionchanged:: 2.0.0
moved from ``cassandra.decoder`` to ``cassandra.query``
""" """
return [OrderedDict(zip(colnames, row)) for row in rows] return [OrderedDict(zip(colnames, row)) for row in rows]
@@ -156,6 +167,8 @@ class Statement(object):
This only takes effect when protocol version 2 or higher is used. This only takes effect when protocol version 2 or higher is used.
See :attr:`.Cluster.protocol_version` for details. See :attr:`.Cluster.protocol_version` for details.
.. versionadded:: 2.0.0
""" """
_serial_consistency_level = None _serial_consistency_level = None
@@ -242,6 +255,8 @@ class Statement(object):
Serial consistency levels may only be used against Cassandra 2.0+ Serial consistency levels may only be used against Cassandra 2.0+
and the :attr:`~.Cluster.protocol_version` must be set to 2 or higher. and the :attr:`~.Cluster.protocol_version` must be set to 2 or higher.
.. versionadded:: 2.0.0
""") """)
@property @property
@@ -494,6 +509,8 @@ class BatchType(object):
""" """
A BatchType is used with :class:`.BatchStatement` instances to control A BatchType is used with :class:`.BatchStatement` instances to control
the atomicity of the batch operation. the atomicity of the batch operation.
.. versionadded:: 2.0.0
""" """
LOGGED = None LOGGED = None
@@ -531,6 +548,8 @@ class BatchStatement(Statement):
""" """
A protocol-level batch of operations which are applied atomically A protocol-level batch of operations which are applied atomically
by default. by default.
.. versionadded:: 2.0.0
""" """
batch_type = None batch_type = None
@@ -574,7 +593,7 @@ class BatchStatement(Statement):
batch.add(SimpleStatement("DELETE FROM pending_users WHERE name=%s", (name,)) batch.add(SimpleStatement("DELETE FROM pending_users WHERE name=%s", (name,))
session.execute(batch) session.execute(batch)
.. versionadded:: 2.0.0b1 .. versionadded:: 2.0.0
""" """
self.batch_type = batch_type self.batch_type = batch_type
self._statements_and_parameters = [] self._statements_and_parameters = []

View File

@@ -5,16 +5,16 @@
.. function:: tuple_factory .. function:: tuple_factory
**Deprecated** Use :meth:`cassandra.query.tuple_factory` **Deprecated in 2.0.0.** Use :meth:`cassandra.query.tuple_factory`
.. function:: named_tuple_factory .. function:: named_tuple_factory
**Deprecated** Use :meth:`cassandra.query.named_tuple_factory` **Deprecated in 2.0.0.** Use :meth:`cassandra.query.named_tuple_factory`
.. function:: dict_factory .. function:: dict_factory
**Deprecated** Use :meth:`cassandra.query.dict_factory` **Deprecated in 2.0.0.** Use :meth:`cassandra.query.dict_factory`
.. function:: ordered_dict_factory .. function:: ordered_dict_factory
**Deprecated** Use :meth:`cassandra.query.ordered_dict_factory` **Deprecated in 2.0.0.** Use :meth:`cassandra.query.ordered_dict_factory`

View File

@@ -1,5 +1,5 @@
``cassandra.query`` - Prepared Statements and Query Policies ``cassandra.query`` - Prepared Statements, Batch Statements, Tracing, and Row Factories
============================================================ =======================================================================================
.. module:: cassandra.query .. module:: cassandra.query

View File

@@ -58,7 +58,7 @@ now:
* :attr:`cassandra.decoder.tuple_factory` has moved to * :attr:`cassandra.decoder.tuple_factory` has moved to
:attr:`cassandra.query.tuple_factory` :attr:`cassandra.query.tuple_factory`
* :attr:`cassandra.decoder.named_tuple_factory` has moved to * :attr:`cassandra.decoder.named_tuple_factory` has moved to
:attr:`cassandra.query.named_tuple_factory :attr:`cassandra.query.named_tuple_factory`
* :attr:`cassandra.decoder.dict_factory` has moved to * :attr:`cassandra.decoder.dict_factory` has moved to
:attr:`cassandra.query.dict_factory` :attr:`cassandra.query.dict_factory`
* :attr:`cassandra.decoder.ordered_dict_factory` has moved to * :attr:`cassandra.decoder.ordered_dict_factory` has moved to