
    FCfC!                        d Z ddlmZ ddlmZmZmZmZ ddlm	Z	  G d d      Z
 G d de
      Z G d	 d
e
      Z G d de
      Z G d de
      Z G d de
      Zy)zResult class definitions.    )annotations)AnyMappingOptionalcast)InvalidOperationc                  >    e Zd ZdZdZddZd	dZd
dZedd       Z	y)_WriteResultz$Base class for write result classes.)__acknowledgedc                    || _         y N_WriteResult__acknowledged)selfacknowledgeds     O/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/pymongo/results.py__init__z_WriteResult.__init__   s
    *    c                N    | j                   j                   d| j                   dS )N())	__class____name__r   r   s    r   __repr__z_WriteResult.__repr__   s'    ..))*!D,?,?+@BBr   c                :    | j                   st        d| d      y)z8Raise an exception on property access if unacknowledged.zA value for zi is not available when the write is unacknowledged. Check the acknowledged attribute to avoid this error.N)r   r   )r   property_names     r   _raise_if_unacknowledgedz%_WriteResult._raise_if_unacknowledged"   s.    """}o .   #r   c                    | j                   S )aC  Is this the result of an acknowledged write operation?

        The :attr:`acknowledged` attribute will be ``False`` when using
        ``WriteConcern(w=0)``, otherwise ``True``.

        .. note::
          If the :attr:`acknowledged` attribute is ``False`` all other
          attributes of this class will raise
          :class:`~pymongo.errors.InvalidOperation` when accessed. Values for
          other attributes cannot be determined if the write operation was
          unacknowledged.

        .. seealso::
          :class:`~pymongo.write_concern.WriteConcern`
        r   r   s    r   r   z_WriteResult.acknowledged,   s    " """r   N)r   boolreturnNoner!   str)r   r$   r!   r"   )r!   r    )
r   
__module____qualname____doc__	__slots__r   r   r   propertyr    r   r   r
   r
      s.    .#I+C # #r   r
   c                  B     e Zd ZdZdZd fdZddZedd       Z xZ	S )	InsertOneResultzFThe return type for :meth:`~pymongo.collection.Collection.insert_one`.)__inserted_idc                2    || _         t        | 	  |       y r   )_InsertOneResult__inserted_idsuperr   )r   inserted_idr   r   s      r   r   zInsertOneResult.__init__E   s    (&r   c                h    | j                   j                   d| j                  d| j                   dS Nr   z, acknowledged=r   )r   r   r/   r   r   s    r   r   zInsertOneResult.__repr__I   s7    ~~&&'q););(>odN_N_M``ab	
r   c                    | j                   S )zThe inserted document's _id.)r/   r   s    r   r1   zInsertOneResult.inserted_idN   s     !!!r   )r1   r   r   r    r!   r"   r#   r!   r   )
r   r%   r&   r'   r(   r   r   r)   r1   __classcell__r   s   @r   r,   r,   @   s)    P"I'

 " "r   r,   c                  B     e Zd ZdZdZd fdZddZedd       Z xZ	S )	InsertManyResultzGThe return type for :meth:`~pymongo.collection.Collection.insert_many`.)__inserted_idsc                2    || _         t        | 	  |       y r   )_InsertManyResult__inserted_idsr0   r   )r   inserted_idsr   r   s      r   r   zInsertManyResult.__init__Y   s    *&r   c                h    | j                   j                   d| j                  d| j                   dS r3   )r   r   r<   r   r   s    r   r   zInsertManyResult.__repr__]   s7    ~~&&'q)<)<(?tO`O`Naabc	
r   c                    | j                   S )a@  A list of _ids of the inserted documents, in the order provided.

        .. note:: If ``False`` is passed for the `ordered` parameter to
          :meth:`~pymongo.collection.Collection.insert_many` the server
          may have inserted the documents in a different order than what
          is presented here.
        )r<   r   s    r   r=   zInsertManyResult.inserted_idsb   s     """r   )r=   	list[Any]r   r    r!   r"   r#   )r!   r@   )
r   r%   r&   r'   r(   r   r   r)   r=   r6   r7   s   @r   r9   r9   T   s)    Q#I'

 # #r   r9   c                  x     e Zd ZdZdZd	 fdZd
dZedd       Zedd       Z	edd       Z
edd       Z xZS )UpdateResultzThe return type for :meth:`~pymongo.collection.Collection.update_one`,
    :meth:`~pymongo.collection.Collection.update_many`, and
    :meth:`~pymongo.collection.Collection.replace_one`.
    __raw_resultc                2    || _         t        | 	  |       y r   )_UpdateResult__raw_resultr0   r   r   
raw_resultr   r   s      r   r   zUpdateResult.__init__v       &&r   c                h    | j                   j                   d| j                  d| j                   dS r3   )r   r   rF   r   r   s    r   r   zUpdateResult.__repr__z   6    ..))*!D,=,=+@PTPaPaObbcddr   c                    | j                   S z/The raw result document returned by the server.)rF   r   s    r   rH   zUpdateResult.raw_result}           r   c                    | j                  d       | j                  y| j                  J | j                  j                  dd      S )z0The number of documents matched for this update.matched_countr   n)r   upserted_idrF   getr   s    r   rP   zUpdateResult.matched_count   sL     	%%o6'  ,,,  $$S!,,r   c                    | j                  d       | j                  J t        t        | j                  j	                  d            S z!The number of documents modified.modified_count	nModified)r   rF   r   intrS   r   s    r   rV   zUpdateResult.modified_count   sC     	%%&67  ,,,C**..{;<<r   c                v    | j                  d       | j                  J | j                  j                  d      S )z^The _id of the inserted document if an upsert took place. Otherwise
        ``None``.
        rR   upserted)r   rF   rS   r   s    r   rR   zUpdateResult.upserted_id   s;    
 	%%m4  ,,,  $$Z00r   )rH   Optional[Mapping[str, Any]]r   r    r#   )r!   r[   r!   rX   r5   )r   r%   r&   r'   r(   r   r   r)   rH   rP   rV   rR   r6   r7   s   @r   rB   rB   n   sj    
 "I'e ! ! - - = = 1 1r   rB   c                  T     e Zd ZdZdZd fdZddZed	d       Zed
d       Z	 xZ
S )DeleteResultzThe return type for :meth:`~pymongo.collection.Collection.delete_one`
    and :meth:`~pymongo.collection.Collection.delete_many`
    rC   c                2    || _         t        | 	  |       y r   )_DeleteResult__raw_resultr0   r   rG   s      r   r   zDeleteResult.__init__   rI   r   c                h    | j                   j                   d| j                  d| j                   dS r3   )r   r   r`   r   r   s    r   r   zDeleteResult.__repr__   rK   r   c                    | j                   S rM   )r`   r   s    r   rH   zDeleteResult.raw_result   rN   r   c                \    | j                  d       | j                  j                  dd      S ) The number of documents deleted.deleted_countrQ   r   )r   r`   rS   r   s    r   re   zDeleteResult.deleted_count   s+     	%%o6  $$S!,,r   )rH   Mapping[str, Any]r   r    r!   r"   r#   )r!   rf   r\   )r   r%   r&   r'   r(   r   r   r)   rH   re   r6   r7   s   @r   r^   r^      sB     "I'e ! ! - -r   r^   c                       e Zd ZdZdZd fdZddZedd       Zedd       Z	edd       Z
edd       Zedd	       Zedd
       Zedd       Z xZS )BulkWriteResultz-An object wrapper for bulk API write results.)__bulk_api_resultc                2    || _         t        | 	  |       y)a)  Create a BulkWriteResult instance.

        :param bulk_api_result: A result dict from the bulk API
        :param acknowledged: Was this write result acknowledged? If ``False``
            then all properties of this object will raise
            :exc:`~pymongo.errors.InvalidOperation`.
        N)!_BulkWriteResult__bulk_api_resultr0   r   )r   bulk_api_resultr   r   s      r   r   zBulkWriteResult.__init__   s     "1&r   c                h    | j                   j                   d| j                  d| j                   dS r3   )r   r   rk   r   r   s    r   r   zBulkWriteResult.__repr__   s6    ..))*!D,B,B+E_UYUfUfTgghiir   c                    | j                   S )zThe raw bulk API result.)rk   r   s    r   rl   zBulkWriteResult.bulk_api_result   s     %%%r   c                v    | j                  d       t        t        | j                  j	                  d            S )z!The number of documents inserted.inserted_count	nInsertedr   r   rX   rk   rS   r   s    r   rp   zBulkWriteResult.inserted_count   1     	%%&67C//33K@AAr   c                v    | j                  d       t        t        | j                  j	                  d            S )z.The number of documents matched for an update.rP   nMatchedrr   r   s    r   rP   zBulkWriteResult.matched_count   0     	%%o6C//33J?@@r   c                v    | j                  d       t        t        | j                  j	                  d            S rU   rr   r   s    r   rV   zBulkWriteResult.modified_count   rs   r   c                v    | j                  d       t        t        | j                  j	                  d            S )rd   re   nRemovedrr   r   s    r   re   zBulkWriteResult.deleted_count   rv   r   c                v    | j                  d       t        t        | j                  j	                  d            S )z!The number of documents upserted.upserted_count	nUpsertedrr   r   s    r   r{   zBulkWriteResult.upserted_count   rs   r   c                    | j                  d       | j                  r$| j                  d   D ci c]  }|d   |d    c}S yc c}w )z=A map of operation index to the _id of the upserted document.upserted_idsrZ   index_idN)r   rk   rl   )r   upserts     r   r~   zBulkWriteResult.upserted_ids   sN     	%%n5!!AEAUAUV`AabvF7OVE]2bb cs   A)rl   dict[str, Any]r   r    r!   r"   r#   )r!   r   r\   )r!   zOptional[dict[int, Any]])r   r%   r&   r'   r(   r   r   r)   rl   rp   rP   rV   re   r{   r~   r6   r7   s   @r   rh   rh      s    7&I	'j & & B B
 A A
 B B
 A A
 B B
  r   rh   N)r'   
__future__r   typingr   r   r   r   pymongo.errorsr   r
   r,   r9   rB   r^   rh   r*   r   r   <module>r      s^      " / / +&# &#R"l "(#| #4+1< +1\-< -4<l <r   