Remove ancient version annotations.
Delete "versionchanged" and "versionadded" directives that predate 2.0.
This commit is contained in:
parent
429aa9c582
commit
08dccbba46
@ -717,7 +717,6 @@ def decode_all(data, as_class=dict,
|
||||
|
||||
.. versionchanged:: 2.7
|
||||
Added `compile_re` option.
|
||||
.. versionadded:: 1.9
|
||||
"""
|
||||
opts = (as_class, tz_aware, uuid_subtype, compile_re)
|
||||
docs = []
|
||||
@ -787,8 +786,6 @@ class BSON(bytes):
|
||||
- `check_keys` (optional): check if keys start with '$' or
|
||||
contain '.', raising :class:`~bson.errors.InvalidDocument` in
|
||||
either case
|
||||
|
||||
.. versionadded:: 1.9
|
||||
"""
|
||||
return cls(_dict_to_bson(document, check_keys, uuid_subtype))
|
||||
|
||||
@ -823,7 +820,6 @@ class BSON(bytes):
|
||||
|
||||
.. versionchanged:: 2.7
|
||||
Added ``compile_re`` option.
|
||||
.. versionadded:: 1.9
|
||||
"""
|
||||
return _bson_to_dict(
|
||||
self, as_class, tz_aware, uuid_subtype, compile_re)
|
||||
@ -831,7 +827,5 @@ class BSON(bytes):
|
||||
|
||||
def has_c():
|
||||
"""Is the C extension installed?
|
||||
|
||||
.. versionadded:: 1.9
|
||||
"""
|
||||
return _USE_C
|
||||
|
||||
@ -23,14 +23,10 @@ BINARY_SUBTYPE = 0
|
||||
"""BSON binary subtype for binary data.
|
||||
|
||||
This is the default subtype for binary data.
|
||||
|
||||
.. versionadded:: 1.5
|
||||
"""
|
||||
|
||||
FUNCTION_SUBTYPE = 1
|
||||
"""BSON binary subtype for functions.
|
||||
|
||||
.. versionadded:: 1.5
|
||||
"""
|
||||
|
||||
OLD_BINARY_SUBTYPE = 2
|
||||
@ -38,8 +34,6 @@ OLD_BINARY_SUBTYPE = 2
|
||||
|
||||
This is the old default subtype, the current
|
||||
default is :data:`BINARY_SUBTYPE`.
|
||||
|
||||
.. versionadded:: 1.7
|
||||
"""
|
||||
|
||||
OLD_UUID_SUBTYPE = 3
|
||||
@ -60,7 +54,6 @@ change to this in a future release.
|
||||
|
||||
.. versionchanged:: 2.1
|
||||
Changed to subtype 4.
|
||||
.. versionadded:: 1.5
|
||||
"""
|
||||
|
||||
JAVA_LEGACY = 5
|
||||
@ -89,14 +82,10 @@ ALL_UUID_SUBTYPES = (OLD_UUID_SUBTYPE, UUID_SUBTYPE, JAVA_LEGACY, CSHARP_LEGACY)
|
||||
|
||||
MD5_SUBTYPE = 5
|
||||
"""BSON binary subtype for an MD5 hash.
|
||||
|
||||
.. versionadded:: 1.5
|
||||
"""
|
||||
|
||||
USER_DEFINED_SUBTYPE = 128
|
||||
"""BSON binary subtype for any user defined structure.
|
||||
|
||||
.. versionadded:: 1.5
|
||||
"""
|
||||
|
||||
|
||||
|
||||
@ -38,9 +38,6 @@ class Code(str):
|
||||
strings) to values
|
||||
- `**kwargs` (optional): scope variables can also be passed as
|
||||
keyword arguments
|
||||
|
||||
.. versionadded:: 1.9
|
||||
Ability to pass scope values using keyword arguments.
|
||||
"""
|
||||
|
||||
_type_marker = 13
|
||||
|
||||
@ -43,11 +43,6 @@ class DBRef(object):
|
||||
- `**kwargs` (optional): additional keyword arguments will
|
||||
create additional, custom fields
|
||||
|
||||
.. versionchanged:: 1.8
|
||||
Now takes keyword arguments to specify additional fields.
|
||||
.. versionadded:: 1.1.1
|
||||
The `database` parameter.
|
||||
|
||||
.. mongodoc:: dbrefs
|
||||
"""
|
||||
if not isinstance(collection, string_type):
|
||||
@ -80,8 +75,6 @@ class DBRef(object):
|
||||
"""Get the name of this DBRef's database.
|
||||
|
||||
Returns None if this DBRef doesn't specify a database.
|
||||
|
||||
.. versionadded:: 1.1.1
|
||||
"""
|
||||
return self.__database
|
||||
|
||||
@ -130,18 +123,12 @@ class DBRef(object):
|
||||
return not self == other
|
||||
|
||||
def __hash__(self):
|
||||
"""Get a hash value for this :class:`DBRef`.
|
||||
|
||||
.. versionadded:: 1.1
|
||||
"""
|
||||
"""Get a hash value for this :class:`DBRef`."""
|
||||
return hash((self.__collection, self.__id, self.__database,
|
||||
tuple(sorted(self.__kwargs.items()))))
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
"""Support function for `copy.deepcopy()`.
|
||||
|
||||
.. versionadded:: 1.10
|
||||
"""
|
||||
"""Support function for `copy.deepcopy()`."""
|
||||
return DBRef(deepcopy(self.__collection, memo),
|
||||
deepcopy(self.__id, memo),
|
||||
deepcopy(self.__database, memo),
|
||||
|
||||
@ -59,21 +59,6 @@ but it will be faster as there is less recursion.
|
||||
Added dumps and loads helpers to automatically handle conversion to and
|
||||
from json and supports :class:`~bson.binary.Binary` and
|
||||
:class:`~bson.code.Code`
|
||||
|
||||
.. versionchanged:: 1.9
|
||||
Handle :class:`uuid.UUID` instances, whenever possible.
|
||||
|
||||
.. versionchanged:: 1.8
|
||||
Handle timezone aware datetime instances on encode, decode to
|
||||
timezone aware datetime instances.
|
||||
|
||||
.. versionchanged:: 1.8
|
||||
Added support for encoding/decoding :class:`~bson.max_key.MaxKey`
|
||||
and :class:`~bson.min_key.MinKey`, and for encoding
|
||||
:class:`~bson.timestamp.Timestamp`.
|
||||
|
||||
.. versionchanged:: 1.2
|
||||
Added support for encoding/decoding datetimes and regular expressions.
|
||||
"""
|
||||
|
||||
import base64
|
||||
|
||||
@ -72,10 +72,6 @@ class ObjectId(object):
|
||||
- `oid` (optional): a valid ObjectId (12 byte binary or 24 character
|
||||
hex string)
|
||||
|
||||
.. versionadded:: 1.2.1
|
||||
The `oid` parameter can be a ``unicode`` instance (that contains
|
||||
only hexadecimal digits).
|
||||
|
||||
.. mongodoc:: objectids
|
||||
"""
|
||||
if oid is None:
|
||||
@ -112,12 +108,6 @@ class ObjectId(object):
|
||||
:Parameters:
|
||||
- `generation_time`: :class:`~datetime.datetime` to be used
|
||||
as the generation time for the resulting ObjectId.
|
||||
|
||||
.. versionchanged:: 1.8
|
||||
Properly handle timezone aware values for
|
||||
`generation_time`.
|
||||
|
||||
.. versionadded:: 1.6
|
||||
"""
|
||||
if generation_time.utcoffset() is not None:
|
||||
generation_time = generation_time - generation_time.utcoffset()
|
||||
@ -204,11 +194,6 @@ class ObjectId(object):
|
||||
The :class:`datetime.datetime` is timezone aware, and
|
||||
represents the generation time in UTC. It is precise to the
|
||||
second.
|
||||
|
||||
.. versionchanged:: 1.8
|
||||
Now return an aware datetime instead of a naive one.
|
||||
|
||||
.. versionadded:: 1.2
|
||||
"""
|
||||
timestamp = struct.unpack(">i", self.__id[0:4])[0]
|
||||
return datetime.datetime.fromtimestamp(timestamp, utc)
|
||||
@ -275,8 +260,5 @@ class ObjectId(object):
|
||||
return NotImplemented
|
||||
|
||||
def __hash__(self):
|
||||
"""Get a hash value for this :class:`ObjectId`.
|
||||
|
||||
.. versionadded:: 1.1
|
||||
"""
|
||||
"""Get a hash value for this :class:`ObjectId`."""
|
||||
return hash(self.__id)
|
||||
|
||||
@ -46,9 +46,6 @@ class Timestamp(object):
|
||||
:class:`~datetime.datetime`, or an aware
|
||||
:class:`~datetime.datetime`
|
||||
- `inc`: the incrementing counter
|
||||
|
||||
.. versionchanged:: 1.7
|
||||
`time` can now be a :class:`~datetime.datetime` instance.
|
||||
"""
|
||||
if isinstance(time, datetime.datetime):
|
||||
if time.utcoffset() is not None:
|
||||
@ -114,7 +111,6 @@ class Timestamp(object):
|
||||
"""Return a :class:`~datetime.datetime` instance corresponding
|
||||
to the time portion of this :class:`Timestamp`.
|
||||
|
||||
.. versionchanged:: 1.8
|
||||
The returned datetime is now timezone aware.
|
||||
The returned datetime's timezone is UTC.
|
||||
"""
|
||||
return datetime.datetime.fromtimestamp(self.__time, utc)
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
:mod:`json_util` -- Tools for using Python's :mod:`json` module with BSON documents
|
||||
======================================================================================
|
||||
.. versionadded:: 1.1.1
|
||||
|
||||
.. automodule:: bson.json_util
|
||||
:synopsis: Tools for using Python's json module with BSON documents
|
||||
:members:
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
:mod:`max_key` -- Representation for the MongoDB internal MaxKey type
|
||||
=====================================================================
|
||||
.. versionadded:: 1.7
|
||||
|
||||
.. automodule:: bson.max_key
|
||||
:synopsis: Representation for the MongoDB internal MaxKey type
|
||||
:members:
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
:mod:`min_key` -- Representation for the MongoDB internal MinKey type
|
||||
=====================================================================
|
||||
.. versionadded:: 1.7
|
||||
|
||||
.. automodule:: bson.min_key
|
||||
:synopsis: Representation for the MongoDB internal MinKey type
|
||||
:members:
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
:mod:`timestamp` -- Tools for representing MongoDB internal Timestamps
|
||||
======================================================================
|
||||
.. versionadded:: 1.5
|
||||
|
||||
.. automodule:: bson.timestamp
|
||||
:synopsis: Tools for representing MongoDB internal Timestamps
|
||||
:members:
|
||||
|
||||
@ -10,9 +10,6 @@ Geospatial Indexing Example
|
||||
This example shows how to create and use a :data:`~pymongo.GEO2D`
|
||||
index in PyMongo.
|
||||
|
||||
.. note:: 2D indexes require server version **>= 1.3.4**. Support for
|
||||
2D indexes also requires PyMongo version **>= 1.5.1**.
|
||||
|
||||
.. mongodoc:: geo
|
||||
|
||||
Creating a Geospatial Index
|
||||
|
||||
@ -87,8 +87,6 @@ class GridFS(object):
|
||||
|
||||
:Parameters:
|
||||
- `**kwargs` (optional): keyword arguments for file creation
|
||||
|
||||
.. versionadded:: 1.6
|
||||
"""
|
||||
# No need for __ensure_index_files_id() here; GridIn ensures
|
||||
# the (files_id, n) index when needed.
|
||||
@ -121,12 +119,6 @@ class GridFS(object):
|
||||
:Parameters:
|
||||
- `data`: data to be written as a file.
|
||||
- `**kwargs` (optional): keyword arguments for file creation
|
||||
|
||||
.. versionadded:: 1.9
|
||||
The ability to write :class:`unicode`, if an `encoding` has
|
||||
been specified as a keyword argument.
|
||||
|
||||
.. versionadded:: 1.6
|
||||
"""
|
||||
grid_file = GridIn(self.__collection, **kwargs)
|
||||
|
||||
@ -150,8 +142,6 @@ class GridFS(object):
|
||||
|
||||
:Parameters:
|
||||
- `file_id`: ``"_id"`` of the file to get
|
||||
|
||||
.. versionadded:: 1.6
|
||||
"""
|
||||
gout = GridOut(self.__collection, file_id)
|
||||
|
||||
@ -189,12 +179,6 @@ class GridFS(object):
|
||||
- `version` (optional): version of the file to get (defaults
|
||||
to -1, the most recent version uploaded)
|
||||
- `**kwargs` (optional): find files by custom metadata.
|
||||
|
||||
.. versionchanged:: 1.11
|
||||
`filename` defaults to None;
|
||||
.. versionadded:: 1.11
|
||||
Accept keyword arguments to find files by custom metadata.
|
||||
.. versionadded:: 1.9
|
||||
"""
|
||||
self.__ensure_index_filename()
|
||||
query = kwargs
|
||||
@ -223,13 +207,6 @@ class GridFS(object):
|
||||
:Parameters:
|
||||
- `filename`: ``"filename"`` of the file to get, or `None`
|
||||
- `**kwargs` (optional): find files by custom metadata.
|
||||
|
||||
.. versionchanged:: 1.11
|
||||
`filename` defaults to None;
|
||||
.. versionadded:: 1.11
|
||||
Accept keyword arguments to find files by custom metadata. See
|
||||
:meth:`get_version`.
|
||||
.. versionadded:: 1.6
|
||||
"""
|
||||
return self.get_version(filename=filename, **kwargs)
|
||||
|
||||
@ -250,8 +227,6 @@ class GridFS(object):
|
||||
|
||||
:Parameters:
|
||||
- `file_id`: ``"_id"`` of the file to delete
|
||||
|
||||
.. versionadded:: 1.6
|
||||
"""
|
||||
self.__ensure_index_files_id()
|
||||
self.__files.remove({"_id": file_id},
|
||||
@ -268,9 +243,6 @@ class GridFS(object):
|
||||
|
||||
.. versionchanged:: 2.7
|
||||
``list`` ensures an index, the same as ``get_version``.
|
||||
|
||||
.. versionchanged:: 1.6
|
||||
Removed the `collection` argument.
|
||||
"""
|
||||
self.__ensure_index_filename()
|
||||
|
||||
@ -400,8 +372,6 @@ class GridFS(object):
|
||||
document to check for
|
||||
- `**kwargs` (optional): keyword arguments are used as a
|
||||
query document, if they're present.
|
||||
|
||||
.. versionadded:: 1.8
|
||||
"""
|
||||
if kwargs:
|
||||
return self.__files.find_one(kwargs, ["_id"]) is not None
|
||||
|
||||
@ -18,29 +18,19 @@ from pymongo.errors import PyMongoError
|
||||
|
||||
|
||||
class GridFSError(PyMongoError):
|
||||
"""Base class for all GridFS exceptions.
|
||||
|
||||
.. versionadded:: 1.5
|
||||
"""
|
||||
"""Base class for all GridFS exceptions."""
|
||||
|
||||
|
||||
class CorruptGridFile(GridFSError):
|
||||
"""Raised when a file in :class:`~gridfs.GridFS` is malformed.
|
||||
"""
|
||||
"""Raised when a file in :class:`~gridfs.GridFS` is malformed."""
|
||||
|
||||
|
||||
class NoFile(GridFSError):
|
||||
"""Raised when trying to read from a non-existent file.
|
||||
|
||||
.. versionadded:: 1.6
|
||||
"""
|
||||
"""Raised when trying to read from a non-existent file."""
|
||||
|
||||
|
||||
class FileExists(GridFSError):
|
||||
"""Raised when trying to create a file that already exists.
|
||||
|
||||
.. versionadded:: 1.7
|
||||
"""
|
||||
"""Raised when trying to create a file that already exists."""
|
||||
|
||||
|
||||
class UnsupportedAPI(GridFSError):
|
||||
@ -50,7 +40,4 @@ class UnsupportedAPI(GridFSError):
|
||||
incompatible changes to the GridFS API. Upgrading shouldn't be
|
||||
difficult, but the old API is no longer supported (with no
|
||||
deprecation period). This exception will be raised when attempting
|
||||
to use unsupported constructs from the old API.
|
||||
|
||||
.. versionadded:: 1.6
|
||||
"""
|
||||
to use unsupported constructs from the old API."""
|
||||
|
||||
@ -318,10 +318,6 @@ class GridIn(object):
|
||||
:Parameters:
|
||||
- `data`: string of bytes or file-like object to be written
|
||||
to the file
|
||||
|
||||
.. versionadded:: 1.9
|
||||
The ability to write :class:`unicode`, if the file has an
|
||||
:attr:`encoding` attribute.
|
||||
"""
|
||||
if self._closed:
|
||||
raise ValueError("cannot write to a closed file")
|
||||
@ -504,8 +500,6 @@ class GridOut(object):
|
||||
|
||||
:Parameters:
|
||||
- `size` (optional): the maximum number of bytes to read
|
||||
|
||||
.. versionadded:: 1.9
|
||||
"""
|
||||
if size == 0:
|
||||
return b''
|
||||
|
||||
@ -22,8 +22,6 @@ DESCENDING = -1
|
||||
GEO2D = "2d"
|
||||
"""Index specifier for a 2-dimensional `geospatial index`_.
|
||||
|
||||
.. versionadded:: 1.5.1
|
||||
|
||||
.. note:: Geo-spatial indexing requires server version **>= 1.3.3**.
|
||||
|
||||
.. _geospatial index: http://docs.mongodb.org/manual/core/2d/
|
||||
@ -93,10 +91,7 @@ from pymongo.mongo_replica_set_client import MongoReplicaSetClient
|
||||
from pymongo.read_preferences import ReadPreference
|
||||
|
||||
def has_c():
|
||||
"""Is the C extension installed?
|
||||
|
||||
.. versionadded:: 1.5
|
||||
"""
|
||||
"""Is the C extension installed?"""
|
||||
try:
|
||||
from pymongo import _cmessage
|
||||
return True
|
||||
|
||||
@ -96,12 +96,6 @@ class Collection(common.BaseObject):
|
||||
.. versionadded:: 2.1
|
||||
uuid_subtype attribute
|
||||
|
||||
.. versionchanged:: 1.5
|
||||
deprecating `options` in favor of kwargs
|
||||
|
||||
.. versionadded:: 1.5
|
||||
the `create` parameter
|
||||
|
||||
.. mongodoc:: collections
|
||||
"""
|
||||
super(Collection, self).__init__(database.read_preference,
|
||||
@ -182,28 +176,18 @@ class Collection(common.BaseObject):
|
||||
"""The full name of this :class:`Collection`.
|
||||
|
||||
The full name is of the form `database_name.collection_name`.
|
||||
|
||||
.. versionchanged:: 1.3
|
||||
``full_name`` is now a property rather than a method.
|
||||
"""
|
||||
return self.__full_name
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""The name of this :class:`Collection`.
|
||||
|
||||
.. versionchanged:: 1.3
|
||||
``name`` is now a property rather than a method.
|
||||
"""
|
||||
"""The name of this :class:`Collection`."""
|
||||
return self.__name
|
||||
|
||||
@property
|
||||
def database(self):
|
||||
"""The :class:`~pymongo.database.Database` that this
|
||||
:class:`Collection` is a part of.
|
||||
|
||||
.. versionchanged:: 1.3
|
||||
``database`` is now a property rather than a method.
|
||||
"""
|
||||
return self.__database
|
||||
|
||||
@ -296,9 +280,6 @@ class Collection(common.BaseObject):
|
||||
|
||||
.. versionchanged:: 3.0
|
||||
Removed the `safe` parameter
|
||||
.. versionadded:: 1.8
|
||||
Support for passing `getLastError` options as keyword
|
||||
arguments.
|
||||
|
||||
.. mongodoc:: insert
|
||||
"""
|
||||
@ -383,11 +364,6 @@ class Collection(common.BaseObject):
|
||||
Removed the `safe` parameter
|
||||
.. versionadded:: 2.1
|
||||
Support for continue_on_error.
|
||||
.. versionadded:: 1.8
|
||||
Support for passing `getLastError` options as keyword
|
||||
arguments.
|
||||
.. versionchanged:: 1.1
|
||||
Bulk insert works with an iterable sequence of documents.
|
||||
|
||||
.. mongodoc:: insert
|
||||
"""
|
||||
@ -533,13 +509,6 @@ class Collection(common.BaseObject):
|
||||
|
||||
.. versionchanged:: 3.0
|
||||
Removed the `safe` parameter
|
||||
.. versionadded:: 1.8
|
||||
Support for passing `getLastError` options as keyword
|
||||
arguments.
|
||||
.. versionchanged:: 1.4
|
||||
Return the response to *lastError* if `safe` is ``True``.
|
||||
.. versionadded:: 1.1.1
|
||||
The `multi` parameter.
|
||||
|
||||
.. _update modifiers: http://www.mongodb.org/display/DOCS/Updating
|
||||
|
||||
@ -610,8 +579,6 @@ class Collection(common.BaseObject):
|
||||
|
||||
>>> db.foo.drop()
|
||||
>>> db.drop_collection("foo")
|
||||
|
||||
.. versionadded:: 1.8
|
||||
"""
|
||||
self.__database.drop_collection(self.__name)
|
||||
|
||||
@ -671,19 +638,6 @@ class Collection(common.BaseObject):
|
||||
|
||||
.. versionchanged:: 3.0
|
||||
Removed the `safe` parameter
|
||||
.. versionadded:: 1.8
|
||||
Support for passing `getLastError` options as keyword arguments.
|
||||
.. versionchanged:: 1.7 Accept any type other than a ``dict``
|
||||
instance for removal by ``"_id"``, not just
|
||||
:class:`~bson.objectid.ObjectId` instances.
|
||||
.. versionchanged:: 1.4
|
||||
Return the response to *lastError* if `safe` is ``True``.
|
||||
.. versionchanged:: 1.2
|
||||
The `spec_or_id` parameter is now optional. If it is
|
||||
not specified *all* documents in the collection will be
|
||||
removed.
|
||||
.. versionadded:: 1.1
|
||||
The `safe` parameter.
|
||||
|
||||
.. mongodoc:: remove
|
||||
"""
|
||||
@ -742,14 +696,6 @@ class Collection(common.BaseObject):
|
||||
specified as part of `**kwargs`, e.g.
|
||||
|
||||
>>> find_one(max_time_ms=100)
|
||||
|
||||
.. versionchanged:: 1.7
|
||||
Allow passing any of the arguments that are valid for
|
||||
:meth:`find`.
|
||||
|
||||
.. versionchanged:: 1.7 Accept any type other than a ``dict``
|
||||
instance as an ``"_id"`` query, not just
|
||||
:class:`~bson.objectid.ObjectId` instances.
|
||||
"""
|
||||
if (spec_or_id is not None and not
|
||||
isinstance(spec_or_id, collections.Mapping)):
|
||||
@ -877,22 +823,6 @@ class Collection(common.BaseObject):
|
||||
.. versionadded:: 2.3
|
||||
The `tag_sets` and `secondary_acceptable_latency_ms` parameters.
|
||||
|
||||
.. versionadded:: 1.11+
|
||||
The `await_data`, `partial`, and `manipulate` parameters.
|
||||
|
||||
.. versionadded:: 1.8
|
||||
The `network_timeout` parameter.
|
||||
|
||||
.. versionadded:: 1.7
|
||||
The `sort`, `max_scan` and `as_class` parameters.
|
||||
|
||||
.. versionchanged:: 1.7
|
||||
The `fields` parameter can now be a dict or any iterable in
|
||||
addition to a list.
|
||||
|
||||
.. versionadded:: 1.1
|
||||
The `tailable` parameter.
|
||||
|
||||
.. mongodoc:: find
|
||||
"""
|
||||
return Cursor(self, *args, **kwargs)
|
||||
@ -1041,12 +971,6 @@ class Collection(common.BaseObject):
|
||||
.. versionchanged:: 2.2
|
||||
Removed deprecated argument: deprecated_unique
|
||||
|
||||
.. versionchanged:: 1.5.1
|
||||
Accept kwargs to support all index creation options.
|
||||
|
||||
.. versionadded:: 1.5
|
||||
The `name` parameter.
|
||||
|
||||
.. seealso:: :meth:`ensure_index`
|
||||
|
||||
.. mongodoc:: indexes
|
||||
@ -1176,12 +1100,6 @@ class Collection(common.BaseObject):
|
||||
.. versionchanged:: 2.2
|
||||
Removed deprecated argument: deprecated_unique
|
||||
|
||||
.. versionchanged:: 1.5.1
|
||||
Accept kwargs to support all index creation options.
|
||||
|
||||
.. versionadded:: 1.5
|
||||
The `name` parameter.
|
||||
|
||||
.. seealso:: :meth:`create_index`
|
||||
"""
|
||||
if "name" in kwargs:
|
||||
@ -1245,8 +1163,6 @@ class Collection(common.BaseObject):
|
||||
.. warning:: reindex blocks all other operations (indexes
|
||||
are built in the foreground) and will be slow for large
|
||||
collections.
|
||||
|
||||
.. versionadded:: 1.11+
|
||||
"""
|
||||
return self.__database.command("reIndex", self.__name,
|
||||
read_preference=ReadPreference.PRIMARY)
|
||||
@ -1269,12 +1185,6 @@ class Collection(common.BaseObject):
|
||||
>>> db.test.index_information()
|
||||
{u'_id_': {u'key': [(u'_id', 1)]},
|
||||
u'x_1': {u'unique': True, u'key': [(u'x', 1)]}}
|
||||
|
||||
|
||||
.. versionchanged:: 1.7
|
||||
The values in the resultant dictionary are now dictionaries
|
||||
themselves, whose ``"key"`` item contains the list that was
|
||||
the value in previous versions of PyMongo.
|
||||
"""
|
||||
raw = self.__database.system.indexes.find({"ns": self.__full_name},
|
||||
{"ns": 0}, as_class=SON)
|
||||
@ -1402,15 +1312,7 @@ class Collection(common.BaseObject):
|
||||
|
||||
.. versionchanged:: 2.2
|
||||
Removed deprecated argument: command
|
||||
|
||||
.. versionchanged:: 1.4
|
||||
The `key` argument can now be ``None`` or a JavaScript function,
|
||||
in addition to a :class:`list` of keys.
|
||||
|
||||
.. versionchanged:: 1.3
|
||||
The `command` argument now defaults to ``True`` and is deprecated.
|
||||
"""
|
||||
|
||||
group = {}
|
||||
if isinstance(key, string_type):
|
||||
group["$keyf"] = Code(key)
|
||||
@ -1443,9 +1345,6 @@ class Collection(common.BaseObject):
|
||||
- `**kwargs` (optional): any additional rename options
|
||||
should be passed as keyword arguments
|
||||
(i.e. ``dropTarget=True``)
|
||||
|
||||
.. versionadded:: 1.7
|
||||
support for accepting keyword arguments for rename options
|
||||
"""
|
||||
if not isinstance(new_name, string_type):
|
||||
raise TypeError("new_name must be an "
|
||||
@ -1478,8 +1377,6 @@ class Collection(common.BaseObject):
|
||||
- `key`: name of key for which we want to get the distinct values
|
||||
|
||||
.. note:: Requires server version **>= 1.1.0**
|
||||
|
||||
.. versionadded:: 1.1.1
|
||||
"""
|
||||
return self.find().distinct(key)
|
||||
|
||||
@ -1516,11 +1413,6 @@ class Collection(common.BaseObject):
|
||||
.. versionchanged:: 2.2
|
||||
Removed deprecated arguments: merge_output and reduce_output
|
||||
|
||||
.. versionchanged:: 1.11+
|
||||
DEPRECATED The merge_output and reduce_output parameters.
|
||||
|
||||
.. versionadded:: 1.2
|
||||
|
||||
.. _map reduce command: http://www.mongodb.org/display/DOCS/MapReduce
|
||||
|
||||
.. mongodoc:: mapreduce
|
||||
@ -1576,8 +1468,6 @@ class Collection(common.BaseObject):
|
||||
>>> db.test.inline_map_reduce(map, reduce, limit=2)
|
||||
|
||||
.. note:: Requires server version **>= 1.7.4**
|
||||
|
||||
.. versionadded:: 1.10
|
||||
"""
|
||||
|
||||
mode = read_preference or self.read_preference
|
||||
@ -1640,8 +1530,6 @@ class Collection(common.BaseObject):
|
||||
|
||||
.. versionchanged:: 2.4
|
||||
Deprecated the use of mapping types for the sort parameter
|
||||
|
||||
.. versionadded:: 1.10
|
||||
"""
|
||||
if (not update and not kwargs.get('remove', None)):
|
||||
raise ValueError("Must either update or remove")
|
||||
|
||||
@ -195,8 +195,6 @@ class Cursor(object):
|
||||
def collection(self):
|
||||
"""The :class:`~pymongo.collection.Collection` that this
|
||||
:class:`Cursor` is iterating.
|
||||
|
||||
.. versionadded:: 1.1
|
||||
"""
|
||||
return self.__collection
|
||||
|
||||
@ -455,8 +453,6 @@ class Cursor(object):
|
||||
|
||||
:Parameters:
|
||||
- `batch_size`: The size of each batch of results requested.
|
||||
|
||||
.. versionadded:: 1.9
|
||||
"""
|
||||
if not isinstance(batch_size, integer_types):
|
||||
raise TypeError("batch_size must be an integer")
|
||||
@ -589,8 +585,6 @@ class Cursor(object):
|
||||
- `max_scan`: the maximum number of documents to scan
|
||||
|
||||
.. note:: Requires server version **>= 1.5.1**
|
||||
|
||||
.. versionadded:: 1.7
|
||||
"""
|
||||
self.__check_okay_to_chain()
|
||||
self.__max_scan = max_scan
|
||||
@ -702,11 +696,6 @@ class Cursor(object):
|
||||
|
||||
.. versionchanged:: 2.8
|
||||
The :meth:`~count` method now supports :meth:`~hint`.
|
||||
|
||||
.. versionadded:: 1.1.1
|
||||
The `with_limit_and_skip` parameter.
|
||||
:meth:`~pymongo.cursor.Cursor.__len__` was deprecated in favor of
|
||||
calling :meth:`count` with `with_limit_and_skip` set to ``True``.
|
||||
"""
|
||||
if not isinstance(with_limit_and_skip, bool):
|
||||
raise TypeError("with_limit_and_skip must be an instance of bool")
|
||||
@ -758,8 +747,6 @@ class Cursor(object):
|
||||
.. note:: Requires server version **>= 1.1.3+**
|
||||
|
||||
.. seealso:: :meth:`pymongo.collection.Collection.distinct`
|
||||
|
||||
.. versionadded:: 1.2
|
||||
"""
|
||||
if not isinstance(key, string_type):
|
||||
raise TypeError("key must be an "
|
||||
@ -1016,8 +1003,6 @@ class Cursor(object):
|
||||
<http://www.mongodb.org/display/DOCS/Tailable+Cursors>`_
|
||||
since they will stop iterating even though they *may* return more
|
||||
results in the future.
|
||||
|
||||
.. versionadded:: 1.5
|
||||
"""
|
||||
return bool(len(self.__data) or (not self.__killed))
|
||||
|
||||
|
||||
@ -124,27 +124,17 @@ class Database(common.BaseObject):
|
||||
"""A :class:`SystemJS` helper for this :class:`Database`.
|
||||
|
||||
See the documentation for :class:`SystemJS` for more details.
|
||||
|
||||
.. versionadded:: 1.5
|
||||
"""
|
||||
return SystemJS(self)
|
||||
|
||||
@property
|
||||
def connection(self):
|
||||
"""The client instance for this :class:`Database`.
|
||||
|
||||
.. versionchanged:: 1.3
|
||||
``connection`` is now a property rather than a method.
|
||||
"""
|
||||
"""The client instance for this :class:`Database`."""
|
||||
return self.__connection
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""The name of this :class:`Database`.
|
||||
|
||||
.. versionchanged:: 1.3
|
||||
``name`` is now a property rather than a method.
|
||||
"""
|
||||
"""The name of this :class:`Database`."""
|
||||
return self.__name
|
||||
|
||||
@property
|
||||
@ -249,9 +239,6 @@ class Database(common.BaseObject):
|
||||
|
||||
.. versionchanged:: 2.2
|
||||
Removed deprecated argument: options
|
||||
|
||||
.. versionchanged:: 1.5
|
||||
deprecating `options` in favor of kwargs
|
||||
"""
|
||||
opts = {"create": True}
|
||||
opts.update(kwargs)
|
||||
@ -443,12 +430,6 @@ class Database(common.BaseObject):
|
||||
.. versionchanged:: 2.2
|
||||
Added support for `as_class` - the class you want to use for
|
||||
the resulting documents
|
||||
.. versionchanged:: 1.6
|
||||
Added the `value` argument for string commands, and keyword
|
||||
arguments for additional command options.
|
||||
.. versionchanged:: 1.5
|
||||
`command` can be a string in addition to a full document.
|
||||
.. versionadded:: 1.4
|
||||
|
||||
.. mongodoc:: commands
|
||||
"""
|
||||
@ -513,11 +494,6 @@ class Database(common.BaseObject):
|
||||
collection. Use with `scandata` for a thorough scan
|
||||
of the structure of the collection and the individual
|
||||
documents. Ignored in MongoDB versions before 1.9.
|
||||
|
||||
.. versionchanged:: 1.11
|
||||
validate_collection previously returned a string.
|
||||
.. versionadded:: 1.11
|
||||
Added `scandata` and `full` options.
|
||||
"""
|
||||
name = name_or_collection
|
||||
if isinstance(name, Collection):
|
||||
@ -788,8 +764,6 @@ class Database(common.BaseObject):
|
||||
|
||||
.. versionchanged:: 2.2
|
||||
Added support for read only users
|
||||
|
||||
.. versionadded:: 1.4
|
||||
"""
|
||||
if not isinstance(name, string_type):
|
||||
raise TypeError("name must be an "
|
||||
@ -834,8 +808,6 @@ class Database(common.BaseObject):
|
||||
|
||||
:Parameters:
|
||||
- `name`: the name of the user to remove
|
||||
|
||||
.. versionadded:: 1.4
|
||||
"""
|
||||
|
||||
try:
|
||||
@ -1023,8 +995,6 @@ class SystemJS(object):
|
||||
0
|
||||
|
||||
.. note:: Requires server version **>= 1.1.1**
|
||||
|
||||
.. versionadded:: 1.5
|
||||
"""
|
||||
# can't just assign it since we've overridden __setattr__
|
||||
object.__setattr__(self, "_db", database)
|
||||
@ -1052,8 +1022,5 @@ class SystemJS(object):
|
||||
return self.__getattr__(name)
|
||||
|
||||
def list(self):
|
||||
"""Get a list of the names of the functions stored in this database.
|
||||
|
||||
.. versionadded:: 1.9
|
||||
"""
|
||||
"""Get a list of the names of the functions stored in this database."""
|
||||
return [x["_id"] for x in self._db.system.js.find(fields=["_id"])]
|
||||
|
||||
@ -23,10 +23,7 @@ except ImportError:
|
||||
|
||||
|
||||
class PyMongoError(Exception):
|
||||
"""Base class for all PyMongo exceptions.
|
||||
|
||||
.. versionadded:: 1.4
|
||||
"""
|
||||
"""Base class for all PyMongo exceptions."""
|
||||
|
||||
|
||||
class ConnectionFailure(PyMongoError):
|
||||
@ -86,9 +83,6 @@ class OperationFailure(PyMongoError):
|
||||
|
||||
.. versionadded:: 2.7
|
||||
The :attr:`details` attribute.
|
||||
|
||||
.. versionadded:: 1.8
|
||||
The :attr:`code` attribute.
|
||||
"""
|
||||
|
||||
def __init__(self, error, code=None, details=None):
|
||||
@ -135,8 +129,6 @@ class ExecutionTimeout(OperationFailure):
|
||||
|
||||
class TimeoutError(OperationFailure):
|
||||
"""DEPRECATED - will be removed in PyMongo 3.0. See WTimeoutError instead.
|
||||
|
||||
.. versionadded:: 1.8
|
||||
"""
|
||||
|
||||
|
||||
@ -152,12 +144,7 @@ class WTimeoutError(TimeoutError):
|
||||
|
||||
|
||||
class DuplicateKeyError(OperationFailure):
|
||||
"""Raised when a safe insert or update fails due to a duplicate key error.
|
||||
|
||||
.. note:: Requires server version **>= 1.3.0**
|
||||
|
||||
.. versionadded:: 1.4
|
||||
"""
|
||||
"""Raised when an insert or update fails due to a duplicate key error."""
|
||||
|
||||
|
||||
class BulkWriteError(OperationFailure):
|
||||
@ -171,25 +158,19 @@ class BulkWriteError(OperationFailure):
|
||||
|
||||
|
||||
class InvalidOperation(PyMongoError):
|
||||
"""Raised when a client attempts to perform an invalid operation.
|
||||
"""
|
||||
"""Raised when a client attempts to perform an invalid operation."""
|
||||
|
||||
|
||||
class InvalidName(PyMongoError):
|
||||
"""Raised when an invalid name is used.
|
||||
"""
|
||||
"""Raised when an invalid name is used."""
|
||||
|
||||
|
||||
class CollectionInvalid(PyMongoError):
|
||||
"""Raised when collection validation fails.
|
||||
"""
|
||||
"""Raised when collection validation fails."""
|
||||
|
||||
|
||||
class InvalidURI(ConfigurationError):
|
||||
"""Raised when trying to parse an invalid mongodb URI.
|
||||
|
||||
.. versionadded:: 1.5
|
||||
"""
|
||||
"""Raised when trying to parse an invalid mongodb URI."""
|
||||
|
||||
|
||||
class UnsupportedOption(ConfigurationError):
|
||||
|
||||
@ -18,8 +18,6 @@ MongoDB.
|
||||
|
||||
.. note:: This module is for internal use and is generally not needed by
|
||||
application developers.
|
||||
|
||||
.. versionadded:: 1.1.2
|
||||
"""
|
||||
|
||||
import random
|
||||
|
||||
Loading…
Reference in New Issue
Block a user