U
    ð¤ùda	  ã                   @   s0   d Z ddlmZmZmZ G dd„ dƒZeƒ ZdS )z%Tools for working with read concerns.é    )ÚAnyÚDictÚOptionalc                   @   s†   e Zd ZdZdee ddœdd„Zeee dœdd„ƒZee	dœd	d
„ƒZ
eeeef dœdd„ƒZee	dœdd„Zedœdd„ZdS )ÚReadConcerna   ReadConcern

    :Parameters:
        - `level`: (string) The read concern level specifies the level of
          isolation for read operations.  For example, a read operation using a
          read concern level of ``majority`` will only return data that has been
          written to a majority of nodes. If the level is left unspecified, the
          server default will be used.

    .. versionadded:: 3.2

    N)ÚlevelÚreturnc                 C   s&   |d kst |tƒr|| _ntdƒ‚d S )Nzlevel must be a string or None.)Ú
isinstanceÚstrÚ_ReadConcern__levelÚ	TypeError)Úselfr   © r   ú8/tmp/pip-unpacked-wheel-oblwsawz/pymongo/read_concern.pyÚ__init__"   s    zReadConcern.__init__)r   c                 C   s   | j S )zThe read concern level.)r
   ©r   r   r   r   r   (   s    zReadConcern.levelc                 C   s   | j dkp| j dkS )zdReturn ``True`` if this read concern is compatible with
        old wire protocol versions.
        NÚlocal©r   r   r   r   r   Úok_for_legacy-   s    zReadConcern.ok_for_legacyc                 C   s   i }| j r| j|d< |S )zÖThe document representation of this read concern.

        .. note::
          :class:`ReadConcern` is immutable. Mutating the value of
          :attr:`document` does not mutate this :class:`ReadConcern`.
        r   )r
   r   )r   Údocr   r   r   Údocument4   s    
zReadConcern.document)Úotherr   c                 C   s   t |tƒr| j|jkS tS )N)r   r   r   ÚNotImplemented)r   r   r   r   r   Ú__eq__A   s    
zReadConcern.__eq__c                 C   s   | j rd| j  S dS )NzReadConcern(%s)zReadConcern()r   r   r   r   r   Ú__repr__F   s    
zReadConcern.__repr__)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r	   r   Úpropertyr   Úboolr   r   r   r   r   r   r   r   r   r   r      s   r   N)r   Útypingr   r   r   r   ZDEFAULT_READ_CONCERNr   r   r   r   Ú<module>   s   8