
    h                     H    d Z ddlmZmZ ddlmZ  G d de      Z e       Zy)z&Tools for working with write concerns.    )integer_typesstring_type)ConfigurationErrorc                   ^    e Zd ZdZdZddZed        Zed        Zed        Z	d Z
d	 Zd
 Zy)WriteConcerna!  WriteConcern

    :Parameters:
        - `w`: (integer or string) Used with replication, write operations
          will block until they have been replicated to the specified number
          or tagged set of servers. `w=<integer>` always includes the replica
          set primary (e.g. w=3 means write to the primary and wait until
          replicated to **two** secondaries). **w=0 disables acknowledgement
          of write operations and can not be used with other write concern
          options.**
        - `wtimeout`: (integer) Used in conjunction with `w`. Specify a value
          in milliseconds to control how long to wait for write propagation
          to complete. If replication does not complete in the given
          timeframe, a timeout exception is raised.
        - `j`: If ``True`` block until write operations have been committed
          to the journal. Cannot be used in combination with `fsync`. Prior
          to MongoDB 2.6 this option was ignored if the server was running
          without journaling. Starting with MongoDB 2.6 write operations will
          fail with an exception if this option is used when the server is
          running without journaling.
        - `fsync`: If ``True`` and the server is running without journaling,
          blocks until the server has synced all data files to disk. If the
          server is running with journaling, this acts the same as the `j`
          option, blocking until write operations have been committed to the
          journal. Cannot be used in combination with `j`.
    )
__document__acknowledged__server_defaultNc                 `   i | _         d| _        |:t        |t              st	        d      |dk  rt        d      || j                   d<   |*t        |t              st	        d      || j                   d<   |9t        |t              st	        d      |r|rt        d	      || j                   d
<   |dk(  r|du rt        d      |Ut        |t              r|dk  rt        d      |dkD  | _        nt        |t              st	        d      || j                   d<   | j                    | _	        y )NTzwtimeout must be an integerr   zwtimeout cannot be less than 0wtimeoutzj must be True or Falsejzfsync must be True or Falsez+Can't set both j and fsync at the same timefsynczCannot set w to 0 and j to Truezw cannot be less than 0zw must be an integer or stringw)
_WriteConcern__document_WriteConcern__acknowledged
isinstancer   	TypeError
ValueErrorboolr   r   _WriteConcern__server_default)selfr   r   r   r   s        X/var/www/html/ranktracker/api/venv/lib/python3.12/site-packages/pymongo/write_concern.py__init__zWriteConcern.__init__3   s5   "h6 =>>!| !ABB*2DOOJ'=a& 9::#$DOOC eT* =>>U( *F G G',DOOG$6a4i$%FGG=!]+q5$%>??&'!e#;/ @AA#$DOOC $(OO 3    c                     | j                   S )z0Does this WriteConcern match the server default.)r   r   s    r   is_server_defaultzWriteConcern.is_server_defaultY   s     $$$r   c                 6    | j                   j                         S )zThe document representation of this write concern.

        .. note::
          :class:`WriteConcern` is immutable. Mutating the value of
          :attr:`document` does not mutate this :class:`WriteConcern`.
        )r   copyr   s    r   documentzWriteConcern.document^   s     ##%%r   c                     | j                   S )z]If ``True`` write operations will wait for acknowledgement before
        returning.
        )r   r   s    r   acknowledgedzWriteConcern.acknowledgedh   s    
 """r   c                 j    ddj                  d | j                  j                         D              dS )NzWriteConcern(z, c              3   &   K   | ]	  }d |z    yw)z%s=%sN ).0kvts     r   	<genexpr>z(WriteConcern.__repr__.<locals>.<genexpr>q   s     GgmGs   ))joinr   itemsr   s    r   __repr__zWriteConcern.__repr__o   s-    IIGt/D/D/FGGJ 	Kr   c                 `    t        |t              r| j                  |j                  k(  S t        S Nr   r   r   r    NotImplementedr   others     r   __eq__zWriteConcern.__eq__s   %    e\*??enn44r   c                 `    t        |t              r| j                  |j                  k7  S t        S r.   r/   r1   s     r   __ne__zWriteConcern.__ne__x   r4   r   )NNNN)__name__
__module____qualname____doc__	__slots__r   propertyr   r    r"   r,   r3   r6   r%   r   r   r   r      sa    6 EI$4L % % & & # #K
r   r   N)	r:   bson.py3compatr   r   pymongo.errorsr   objectr   DEFAULT_WRITE_CONCERNr%   r   r   <module>rA      s)    - 5 -f6 fR % r   