o
    'hC3                     @  s   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 dZG dd deZG d	d
 d
eZG dd deZG dd deZG dd deZG dd deZG dd deZdS )z{Result class definitions.

.. seealso:: This module is compatible with both the synchronous and asynchronous PyMongo APIs.
    )annotations)AnyMappingMutableMappingOptionalcast)InvalidOperationc                   @  s@   e Zd ZdZdZdddZdd
dZdddZedddZ	dS )_WriteResultz$Base class for write result classes.)__acknowledgedacknowledgedboolreturnNonec                 C  s
   || _ d S N_WriteResult__acknowledged)selfr    r   K/var/www/html/olx_land/venv/lib/python3.10/site-packages/pymongo/results.py__init__   s   
z_WriteResult.__init__strc                 C  s   | j j d| j dS )N())	__class____name__r   r   r   r   r   __repr__"   s   z_WriteResult.__repr__property_namec                 C     | j std| ddS )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   r   r   r   r   _raise_if_unacknowledged%   
   
z%_WriteResult._raise_if_unacknowledgedc                 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   r   r   r   r   /   s   z_WriteResult.acknowledgedN)r   r   r   r   r   r   r   r   r   r   r   r   )
r   
__module____qualname____doc__	__slots__r   r   r!   propertyr   r   r   r   r   r	      s    



r	   c                      >   e Zd ZdZdZd fd	d
ZdddZedddZ  Z	S )InsertOneResultzThe return type for :meth:`~pymongo.collection.Collection.insert_one`
    and as part of :meth:`~pymongo.mongo_client.MongoClient.bulk_write`.
    )__inserted_idinserted_idr   r   r   r   r   c                      || _ t | d S r   )_InsertOneResult__inserted_idsuperr   )r   r/   r   r   r   r   r   J      zInsertOneResult.__init__r   c                 C     | j j d| jd| j dS Nr   z, acknowledged=r   )r   r   r1   r   r   r   r   r   r   N      zInsertOneResult.__repr__c                 C  r#   )zThe inserted document's _id.)r1   r   r   r   r   r/   S      zInsertOneResult.inserted_id)r/   r   r   r   r   r   r$   r   r   )
r   r'   r(   r)   r*   r   r   r+   r/   __classcell__r   r   r3   r   r-   C   s    
r-   c                      r,   )InsertManyResultzGThe return type for :meth:`~pymongo.collection.Collection.insert_many`.)__inserted_idsinserted_ids	list[Any]r   r   r   r   c                   r0   r   )_InsertManyResult__inserted_idsr2   r   )r   r=   r   r3   r   r   r   ^   r4   zInsertManyResult.__init__r   c                 C  r5   r6   )r   r   r?   r   r   r   r   r   r   b   r7   zInsertManyResult.__repr__c                 C  r#   )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   r   r   r   r=   g   s   	zInsertManyResult.inserted_ids)r=   r>   r   r   r   r   r$   )r   r>   )
r   r'   r(   r)   r*   r   r   r+   r=   r:   r   r   r3   r   r;   Y   s    
r;   c                      sz   e Zd ZdZdZ	dd fd	d
ZdddZedddZedddZ	edddZ
ed ddZed!ddZ  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_bulkF
raw_resultOptional[Mapping[str, Any]]r   r   in_client_bulkc                   s   || _ || _t | d S r   )_UpdateResult__raw_result_UpdateResult__in_client_bulkr2   r   )r   rC   r   rE   r3   r   r   r      s   zUpdateResult.__init__r   r   c                 C  r5   r6   )r   r   rF   r   r   r   r   r   r         zUpdateResult.__repr__c                 C  r#   z/The raw result document returned by the server.rF   r   r   r   r   rC      r8   zUpdateResult.raw_resultintc                 C  s:   |  d | jdusJ | js| jdurdS | jddS )z0The number of documents matched for this update.matched_countNr   n)r!   rF   rG   upserted_idgetr   r   r   r   rL      s
   
zUpdateResult.matched_countc                 C  s*   |  d | jdusJ tt| jdS )!The number of documents modified.modified_countN	nModified)r!   rF   r   rK   rO   r   r   r   r   rQ      s   
zUpdateResult.modified_countr   c                 C  sF   |  d | jdusJ | jr| jdr| jd d S | jddS )z^The _id of the inserted document if an upsert took place. Otherwise
        ``None``.
        rN   Nupserted_id)r!   rF   rG   rO   r   r   r   r   rN      s
   
zUpdateResult.upserted_idc                 C  s   | j dusJ d| j v S )zEWhether an upsert took place.

        .. versionadded:: 4.9
        NrS   rJ   r   r   r   r   
did_upsert   s   
zUpdateResult.did_upsert)F)rC   rD   r   r   rE   r   r$   )r   rD   r   rK   r9   r&   )r   r'   r(   r)   r*   r   r   r+   rC   rL   rQ   rN   rU   r:   r   r   r3   r   r@   s   s     	


r@   c                      sL   e Zd ZdZdZd fd	d
ZdddZedddZedddZ	  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`.
    )rA   rC   Mapping[str, Any]r   r   r   r   c                   r0   r   )_DeleteResult__raw_resultr2   r   )r   rC   r   r3   r   r   r      r4   zDeleteResult.__init__r   c                 C  r5   r6   )r   r   rY   r   r   r   r   r   r      rH   zDeleteResult.__repr__c                 C  r#   rI   )rY   r   r   r   r   rC      r8   zDeleteResult.raw_resultrK   c                 C  s   |  d | jddS ) The number of documents deleted.deleted_countrM   r   )r!   rY   rO   r   r   r   r   r[      s   
zDeleteResult.deleted_count)rC   rX   r   r   r   r   r$   )r   rX   rV   )r   r'   r(   r)   r*   r   r   r+   rC   r[   r:   r   r   r3   r   rW      s    
rW   c                      s   e Zd ZdZdZd fd	d
ZdddZedddZedddZ	edddZ
edddZedddZedddZ  ZS )_BulkWriteResultBasez.Private base class for bulk write API results.)__bulk_api_resultbulk_api_resultdict[str, Any]r   r   r   r   c                   r0   r   )%_BulkWriteResultBase__bulk_api_resultr2   r   r   r^   r   r3   r   r   r      r4   z_BulkWriteResultBase.__init__r   c                 C  r5   r6   )r   r   r`   r   r   r   r   r   r      rH   z_BulkWriteResultBase.__repr__c                 C  r#   )zThe raw bulk write API result.)r`   r   r   r   r   r^      r8   z$_BulkWriteResultBase.bulk_api_resultrK   c                 C     |  d tt| jdS )z!The number of documents inserted.inserted_count	nInsertedr!   r   rK   r`   rO   r   r   r   r   rc         
z#_BulkWriteResultBase.inserted_countc                 C  rb   )z.The number of documents matched for an update.rL   nMatchedre   r   r   r   r   rL      rf   z"_BulkWriteResultBase.matched_countc                 C  rb   )rP   rQ   rR   re   r   r   r   r   rQ      rf   z#_BulkWriteResultBase.modified_countc                 C  s8   |  d d| jv rtt| jdS tt| jdS )rZ   r[   nRemovednDeleted)r!   r`   r   rK   rO   r   r   r   r   r[      s   

z"_BulkWriteResultBase.deleted_countc                 C  rb   )z!The number of documents upserted.upserted_count	nUpsertedre   r   r   r   r   rj      rf   z#_BulkWriteResultBase.upserted_countr^   r_   r   r   r   r   r$   )r   r_   rV   )r   r'   r(   r)   r*   r   r   r+   r^   rc   rL   rQ   r[   rj   r:   r   r   r3   r   r\      s"    
r\   c                      s>   e Zd ZdZdZd fd	d
ZdddZedddZ  Z	S )BulkWriteResultz>An object wrapper for collection-level bulk write API results.r   r^   r_   r   r   r   r   c                   s   t  || dS )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)r2   r   ra   r3   r   r   r   	  s   zBulkWriteResult.__init__r   c                 C  r5   r6   )r   r   r^   r   r   r   r   r   r     r7   zBulkWriteResult.__repr__Optional[dict[int, Any]]c                 C  s(   |  d | jrdd | jd D S dS )z=A map of operation index to the _id of the upserted document.upserted_idsc                 S  s   i | ]	}|d  |d qS )indexrT   r   ).0upsertr   r   r   
<dictcomp>  s    z0BulkWriteResult.upserted_ids.<locals>.<dictcomp>rS   N)r!   r^   r   r   r   r   ro     s   
zBulkWriteResult.upserted_idsrl   r$   )r   rn   )
r   r'   r(   r)   r*   r   r   r+   ro   r:   r   r   r3   r   rm     s    

rm   c                      sr   e Zd ZdZdZd fd
dZdddZdddZed ddZ	ed!ddZ
ed"ddZed#ddZ  ZS )$ClientBulkWriteResultz:An object wrapper for client-level bulk write API results.)__has_verbose_resultsr^   MutableMapping[str, Any]r   r   has_verbose_resultsr   r   c                   s   || _ t || dS )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_resultsr2   r   )r   r^   r   rw   r3   r   r   r   &  s
   zClientBulkWriteResult.__init__r   c                 C  s   d | jj| j| j| jS )Nz%{}({!r}, acknowledged={}, verbose={}))formatr   r   r^   r   rw   r   r   r   r   r   =  s   zClientBulkWriteResult.__repr__r   c                 C  r   )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)rx   r   r    r   r   r   _raise_if_not_verboseE  r"   z+ClientBulkWriteResult._raise_if_not_verbosec                 C  r#   )z/Whether the returned results should be verbose.)rx   r   r   r   r   rw   N  r8   z)ClientBulkWriteResult.has_verbose_resultsMapping[int, InsertOneResult]c                 C  .   |  d | d ttttf | jdS )z:A map of successful insertion operations to their results.insert_resultsinsertResults)r!   rz   r   r   rK   r-   r^   rO   r   r   r   r   r}   S     



z$ClientBulkWriteResult.insert_resultsMapping[int, UpdateResult]c                 C  r|   )z7A map of successful update operations to their results.update_resultsupdateResults)r!   rz   r   r   rK   r@   r^   rO   r   r   r   r   r   ]  r   z$ClientBulkWriteResult.update_resultsMapping[int, DeleteResult]c                 C  r|   )z7A map of successful delete operations to their results.delete_resultsdeleteResults)r!   rz   r   r   rK   rW   r^   rO   r   r   r   r   r   g  r   z$ClientBulkWriteResult.delete_results)r^   rv   r   r   rw   r   r   r   r$   r%   r&   )r   r{   )r   r   )r   r   )r   r'   r(   r)   r*   r   r   rz   r+   rw   r}   r   r   r:   r   r   r3   r   rt   !  s    

			rt   N)r)   
__future__r   typingr   r   r   r   r   pymongo.errorsr   r	   r-   r;   r@   rW   r\   rm   rt   r   r   r   r   <module>   s   )C3