def __init__(self, doc):
        """Parse an ismaster response from the server."""
        self._server_type = _get_server_type(doc)
        self._doc = doc
        self._is_writable = self._server_type in (
            SERVER_TYPE.RSPrimary,
            SERVER_TYPE.Standalone,
            SERVER_TYPE.Mongos)

        self._is_readable = (
            self.server_type == SERVER_TYPE.RSSecondary
            or self._is_writable)
Parse an ismaster response from the server.
stackoverflow/venv/lib/python3.6/site-packages/pymongo/ismaster.py