

def count(self, with_limit_and_skip=False):
    'Get the size of the results set for this query.\n\n        Returns the number of documents in the results set for this query. Does\n        not take :meth:`limit` and :meth:`skip` into account by default - set\n        `with_limit_and_skip` to ``True`` if that is the desired behavior.\n        Raises :class:`~pymongo.errors.OperationFailure` on a database error.\n\n        With :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`\n        or :class:`~pymongo.master_slave_connection.MasterSlaveConnection`,\n        if `read_preference` is not\n        :attr:`pymongo.read_preferences.ReadPreference.PRIMARY` or\n        :attr:`pymongo.read_preferences.ReadPreference.PRIMARY_PREFERRED`, or\n        (deprecated) `slave_okay` is `True`, the count command will be sent to\n        a secondary or slave.\n\n        :Parameters:\n          - `with_limit_and_skip` (optional): take any :meth:`limit` or\n            :meth:`skip` that has been applied to this cursor into account when\n            getting the count\n\n        .. note:: The `with_limit_and_skip` parameter requires server\n           version **>= 1.1.4-**\n\n        .. note:: ``count`` ignores ``network_timeout``. For example, the\n          timeout is ignored in the following code::\n\n            collection.find({}, network_timeout=1).count()\n\n        .. versionadded:: 1.1.1\n           The `with_limit_and_skip` parameter.\n           :meth:`~pymongo.cursor.Cursor.__len__` was deprecated in favor of\n           calling :meth:`count` with `with_limit_and_skip` set to ``True``.\n        '
    if (not isinstance(with_limit_and_skip, bool)):
        raise TypeError('with_limit_and_skip must be an instance of bool')
    command = {
        'query': self.__spec,
        'fields': self.__fields,
    }
    command['read_preference'] = self.__read_preference
    command['tag_sets'] = self.__tag_sets
    command['secondary_acceptable_latency_ms'] = self.__secondary_acceptable_latency_ms
    command['slave_okay'] = self.__slave_okay
    use_master = ((not self.__slave_okay) and (not self.__read_preference))
    use_master['_use_master'] = use_master
    if (self.__max_time_ms is not None):
        command['maxTimeMS'] = self.__max_time_ms
    if self.__comment:
        command['$comment'] = self.__comment
    if with_limit_and_skip:
        if self.__limit:
            command['limit'] = self.__limit
        if self.__skip:
            command['skip'] = self.__skip
    database = self.__collection.database
    r = database.command('count', self.__collection.name, allowable_errors=['ns missing'], uuid_subtype=self.__uuid_subtype, compile_re=self.__compile_re, **command)
    if (r.get('errmsg', '') == 'ns missing'):
        return 0
    return int(r['n'])

dataset/ETHPy150Open blynch/CloudMemeBackend/pymongo/cursor.py Cursor.count/VarMisuse@110/749 `command`->`use_master`