
    nhC3                        d Z ddlmZ ddlmZ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 G d de      Z G d de      Zy)z{Result class definitions.

.. seealso:: This module is compatible with both the synchronous and asynchronous PyMongo APIs.
    )annotations)AnyMappingMutableMapping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     u/var/www/html/SchoolMeal/SchoolMeal/pds_admin_SchoolMeal/Backend/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.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 )	InsertOneResultzThe return type for :meth:`~pymongo.collection.Collection.insert_one`
    and as part of :meth:`~pymongo.mongo_client.MongoClient.bulk_write`.
    )__inserted_idc                2    || _         t        | 	  |       y r   )_InsertOneResult__inserted_idsuperr   )r   inserted_idr   r   s      r   r   zInsertOneResult.__init__J   s    (&r   c                h    | j                   j                   d| j                  d| j                   dS Nr   z, acknowledged=r   )r   r   r4   r   r   s    r   r   zInsertOneResult.__repr__N   s7    ~~&&'q););(>odN_N_M``ab	
r   c                    | j                   S )zThe inserted document's _id.)r4   r   s    r   r6   zInsertOneResult.inserted_idS   s     !!!r   )r6   r   r   r#   r$   r%   r&   r$   r   )
r   r*   r+   r,   r-   r   r   r.   r6   __classcell__r   s   @r   r1   r1   C   s-     #I'

 " "r   r1   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_idsr5   r   )r   inserted_idsr   r   s      r   r   zInsertManyResult.__init__^   s    *&r   c                h    | j                   j                   d| j                  d| j                   dS r8   )r   r   rA   r   r   s    r   r   zInsertManyResult.__repr__b   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.
        )rA   r   s    r   rB   zInsertManyResult.inserted_idsg   s     """r   )rB   	list[Any]r   r#   r$   r%   r&   )r$   rE   )
r   r*   r+   r,   r-   r   r   r.   rB   r;   r<   s   @r   r>   r>   Y   s)    Q#I'

 # #r   r>   c                       e Zd ZdZdZ	 d
	 	 	 	 	 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 xZS )UpdateResulta  The return type for :meth:`~pymongo.collection.Collection.update_one`,
    :meth:`~pymongo.collection.Collection.update_many`, and
    :meth:`~pymongo.collection.Collection.replace_one`, and as part of
    :meth:`~pymongo.mongo_client.MongoClient.bulk_write`.
    )__raw_result__in_client_bulkc                @    || _         || _        t        |   |       y r   )_UpdateResult__raw_result_UpdateResult__in_client_bulkr5   r   )r   
raw_resultr   in_client_bulkr   s       r   r   zUpdateResult.__init__   s"     ' .&r   c                h    | j                   j                   d| j                  d| j                   dS r8   )r   r   rK   r   r   s    r   r   zUpdateResult.__repr__   6    ..))*!D,=,=+@PTPaPaObbcddr   c                    | j                   S z/The raw result document returned by the server.rK   r   s    r   rM   zUpdateResult.raw_result           r   c                    | j                  d       | j                  J | j                  s| j                  y| j                  j	                  dd      S )z0The number of documents matched for this update.matched_countr   n)r!   rK   rL   upserted_idgetr   s    r   rV   zUpdateResult.matched_count   sT     	%%o6  ,,,$$)9)9)E  $$S!,,r   c                    | j                  d       | j                  J t        t        | j                  j	                  d            S z!The number of documents modified.modified_count	nModified)r!   rK   r   intrY   r   s    r   r\   zUpdateResult.modified_count   sC     	%%&67  ,,,C**..{;<<r   c                    | j                  d       | j                  J | j                  r-| j                  j                  d      r| j                  d   d   S | j                  j                  dd      S )z^The _id of the inserted document if an upsert took place. Otherwise
        ``None``.
        rX   Nupserted_id)r!   rK   rL   rY   r   s    r   rX   zUpdateResult.upserted_id   so    
 	%%m4  ,,,  T%6%6%:%::%F$$Z077  $$Z66r   c                :    | j                   J d| j                   v S )zEWhether an upsert took place.

        .. versionadded:: 4.9
        r`   rS   r   s    r   
did_upsertzUpdateResult.did_upsert   s'       ,,,T....r   )F)rM   Optional[Mapping[str, Any]]r   r#   rN   r#   r&   )r$   rd   r$   r^   r:   r)   )r   r*   r+   r,   r-   r   r   r.   rM   rV   r\   rX   rc   r;   r<   s   @r   rG   rG   s   s    I  %	'/' ' 	'e ! ! - - = = 7 7 / /r   rG   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`
    and as part of :meth:`~pymongo.mongo_client.MongoClient.bulk_write`.
    )rH   c                2    || _         t        | 	  |       y r   )_DeleteResult__raw_resultr5   r   )r   rM   r   r   s      r   r   zDeleteResult.__init__   s    &&r   c                h    | j                   j                   d| j                  d| j                   dS r8   )r   r   ri   r   r   s    r   r   zDeleteResult.__repr__   rP   r   c                    | j                   S rR   )ri   r   s    r   rM   zDeleteResult.raw_result   rT   r   c                \    | j                  d       | j                  j                  dd      S ) The number of documents deleted.deleted_countrW   r   )r!   ri   rY   r   s    r   rn   zDeleteResult.deleted_count   s+     	%%o6  $$S!,,r   )rM   Mapping[str, Any]r   r#   r$   r%   r&   )r$   ro   re   )r   r*   r+   r,   r-   r   r   r.   rM   rn   r;   r<   s   @r   rg   rg      sB    
 "I'e ! ! - -r   rg   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 xZS )_BulkWriteResultBasez.Private base class for bulk write API results.)__bulk_api_resultc                2    || _         t        | 	  |       y r   )%_BulkWriteResultBase__bulk_api_resultr5   r   r   bulk_api_resultr   r   s      r   r   z_BulkWriteResultBase.__init__   s    !0&r   c                h    | j                   j                   d| j                  d| j                   dS r8   )r   r   rt   r   r   s    r   r   z_BulkWriteResultBase.__repr__   s6    ..))*!D,B,B+E_UYUfUfTgghiir   c                    | j                   S )zThe raw bulk write API result.)rt   r   s    r   rv   z$_BulkWriteResultBase.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   r^   rt   rY   r   s    r   rz   z#_BulkWriteResultBase.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.rV   nMatchedr|   r   s    r   rV   z"_BulkWriteResultBase.matched_count   s0     	%%o6C//33J?@@r   c                v    | j                  d       t        t        | j                  j	                  d            S r[   r|   r   s    r   r\   z#_BulkWriteResultBase.modified_count   r}   r   c                    | j                  d       d| j                  v r)t        t        | j                  j	                  d            S t        t        | j                  j	                  d            S )rm   rn   nRemovednDeleted)r!   rt   r   r^   rY   r   s    r   rn   z"_BulkWriteResultBase.deleted_count   s\     	%%o6///T3377
CDDT3377
CDDr   c                v    | j                  d       t        t        | j                  j	                  d            S )z!The number of documents upserted.upserted_count	nUpsertedr|   r   s    r   r   z#_BulkWriteResultBase.upserted_count   r}   r   rv   dict[str, Any]r   r#   r$   r%   r&   )r$   r   re   )r   r*   r+   r,   r-   r   r   r.   rv   rz   rV   r\   rn   r   r;   r<   s   @r   rq   rq      s    8&I'j & & B B
 A A
 B B
 E E B Br   rq   c                  B     e Zd ZdZdZd fdZddZedd       Z xZ	S )	BulkWriteResultz>An object wrapper for collection-level bulk write API results.r/   c                &    t         |   ||       y)a@  Create a BulkWriteResult instance.

        :param bulk_api_result: A result dict from the collection-level bulk write API
        :param acknowledged: Was this write result acknowledged? If ``False``
            then all properties of this object will raise
            :exc:`~pymongo.errors.InvalidOperation`.
        N)r5   r   ru   s      r   r   zBulkWriteResult.__init__	  s     	,7r   c                h    | j                   j                   d| j                  d| j                   dS r8   )r   r   rv   r   r   s    r   r   zBulkWriteResult.__repr__  s8    ~~&&'q)=)=(@PTPaPaObbcd	
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_idsr`   indexra   N)r!   rv   )r   upserts     r   r   zBulkWriteResult.upserted_ids  sN     	%%n5AEAUAUV`AabvF7OVE]2bb cs   Ar   r&   )r$   zOptional[dict[int, Any]])
r   r*   r+   r,   r-   r   r   r.   r   r;   r<   s   @r   r   r     s)    HI8

  r   r   c                       e Zd ZdZdZ	 	 	 	 	 	 	 	 d
 fdZddZddZedd       Z	edd       Z
edd       Zedd	       Z xZS )ClientBulkWriteResultz:An object wrapper for client-level bulk write API results.)__has_verbose_resultsc                4    || _         t        | 	  ||       y)aU  Create a ClientBulkWriteResult instance.

        :param bulk_api_result: A result dict from the client-level bulk write API
        :param acknowledged: Was this write result acknowledged? If ``False``
            then all properties of this object will raise
            :exc:`~pymongo.errors.InvalidOperation`.
        :param has_verbose_results: Should the returned result be verbose?
            If ``False``, then the ``insert_results``, ``update_results``, and
            ``delete_results`` properties of this object will raise
            :exc:`~pymongo.errors.InvalidOperation`.
        N)+_ClientBulkWriteResult__has_verbose_resultsr5   r   )r   rv   r   has_verbose_resultsr   s       r   r   zClientBulkWriteResult.__init__&  s     " &9"	
r   c                    dj                  | j                  j                  | j                  | j                  | j
                        S )Nz%{}({!r}, acknowledged={}, verbose={}))formatr   r   rv   r   r   r   s    r   r   zClientBulkWriteResult.__repr__=  s=    6==NN##  $$	
 	
r   c                :    | j                   st        d| d      y)zARaise an exception on property access if verbose results are off.r   zv is not available when the results are not set to be verbose. Check the verbose_results attribute to avoid this error.N)r   r	   r   s     r   _raise_if_not_verbosez+ClientBulkWriteResult._raise_if_not_verboseE  s0    ))"}o .A A  *r   c                    | j                   S )z/Whether the returned results should be verbose.)r   r   s    r   r   z)ClientBulkWriteResult.has_verbose_resultsN  s     )))r   c                    | j                  d       | j                  d       t        t        t        t
        f   | j                  j                  d            S )z:A map of successful insertion operations to their results.insert_resultsinsertResults)r!   r   r   r   r^   r1   rv   rY   r   s    r   r   z$ClientBulkWriteResult.insert_resultsS  sP     	%%&67""#34C()  $$_5
 	
r   c                    | j                  d       | j                  d       t        t        t        t
        f   | j                  j                  d            S )z7A map of successful update operations to their results.update_resultsupdateResults)r!   r   r   r   r^   rG   rv   rY   r   s    r   r   z$ClientBulkWriteResult.update_results]  P     	%%&67""#34C%&  $$_5
 	
r   c                    | j                  d       | j                  d       t        t        t        t
        f   | j                  j                  d            S )z7A map of successful delete operations to their results.delete_resultsdeleteResults)r!   r   r   r   r^   rg   rv   rY   r   s    r   r   z$ClientBulkWriteResult.delete_resultsg  r   r   )rv   zMutableMapping[str, Any]r   r#   r   r#   r$   r%   r&   r(   r)   )r$   zMapping[int, InsertOneResult])r$   zMapping[int, UpdateResult])r$   zMapping[int, DeleteResult])r   r*   r+   r,   r-   r   r   r   r.   r   r   r   r   r;   r<   s   @r   r   r   !  s    D*I
1
 
 "	

 

.
 * * 
 
 
 
 
 
r   r   N)r,   
__future__r   typingr   r   r   r   r   pymongo.errorsr	   r   r1   r>   rG   rg   rq   r   r   r/   r   r   <module>r      s    # ? ? +&# &#R"l ",#| #4@/< @/F-< -60B< 0Bf* :N
0 N
r   