o
    C©Ìhåï  ã                   @  s  U d Z ddlmZ ddlZddlZddlZddlmZ ddl	m
Z
mZmZmZmZmZmZmZmZ ddlZddlmZmZmZ ddlmZ ddlmZmZmZmZ dd	lmZ dd
l m!Z! z
ddl"m#Z# dZ$W n e%yr   dZ$Y nw ddl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z. ddl/m0Z0m1Z1 e
r¯ddl2m3Z3m4Z4m5Z5 ddl6m7Z7 ddl8m9Z9m:Z:m;Z;m<Z<m=Z= dZ>dZ?dZ@dZAdZBdZCdZDdZEdZFdZGdZHdZIdZJeAdeBd eCd!iZKd"d#d$d%d&œZLed'd(�ZMd)eNd*< død-d.„ZOdùd3d4„ZPdúd8d9„ZQdúd:d;„ZRdûdAdB„ZSddCdDdEdFdGœZTdHdIdJdKdLdMdNdOdPdQdQdRdSœZU			düdýddde„ZVdþdkdl„ZWe Xdm¡jYZZdnZ[dÿdtdu„Z\e Xdv¡jYZ]�d dwdx„Z^e Xdy¡jYZ_e Xdz¡jYZ`e Xd{¡jYZa�ddƒd„„Zb�dd†d‡„Zc�ddˆd‰„Zde$�rbe#jeZd	�d�dd�dŽ„Ze�dd•d–„Zf�dd˜d™„Zg�ddšd›„Zhe$�rƒe#jiZh	�d�d	dœd�„Zje Xdž¡jYZk�d
dŸd „Zl�dd¡d¢„Zm�dd£d¤„Zne$�rªe#joZn	�d�dd¥d¦„ZpeAd§eBd¨eCd©iZqG dªd«„ d«ƒZrG d¬d­„ d­erƒZsG d®d¯„ d¯esƒZt�dd³d´„ZudµZv�dd¼d½„Zw�dd¿dÀ„Zxe$�rìe#jxZx�ddÂdÃ„Zy�ddÄdÅ„Zze$�rþe#jzZz�ddÇdÈ„Z{G dÉdÊ„ dÊerƒZ|dËZ}�ddÐdÑ„Z~�dd×dØ„Z�ddÚdÛ„Z€�ddÝdÞ„Z��ddßdà„Z‚�ddádâ„Zƒ�ddãdä„Z„e$�r>e#j„Z„�ddådæ„Z…G dçdè„ dèƒZ†G dédê„ dêƒZ‡e†jˆe†j‰e‡jˆe‡j‰iZŠdëeNdì< G dídî„ dîƒZ‹G dïdð„ dðƒZŒG dñdò„ dòe‹ƒZ�G dódô„ dôeŒƒZŽG dõdö„ döe�ed÷f ƒZ�dS (  zâTools for creating `messages
<https://www.mongodb.com/docs/manual/reference/mongodb-wire-protocol/>`_ to be sent to
MongoDB.

.. note:: This module is for internal use and is generally not needed by
   application developers.
é    )ÚannotationsN)ÚBytesIO)	ÚTYPE_CHECKINGÚAnyÚCallableÚIterableÚMappingÚMutableMappingÚNoReturnÚOptionalÚUnion)ÚCodecOptionsÚ_dict_to_bsonÚ_make_c_string)ÚInt64)Ú_RAW_ARRAY_BSON_OPTIONSÚDEFAULT_RAW_BSON_OPTIONSÚRawBSONDocumentÚ_inflate_bson)ÚHelloCompat)Ú_EventListeners)Ú	_cmessageTF)ÚConfigurationErrorÚCursorNotFoundÚDocumentTooLargeÚExecutionTimeoutÚInvalidOperationÚNotPrimaryErrorÚOperationFailureÚProtocolError)ÚReadPreferenceÚ_ServerMode)ÚSnappyContextÚZlibContextÚZstdContext)ÚReadConcern)Ú_AddressÚ_AgnosticClientSessionÚ_AgnosticConnectionÚ_AgnosticMongoClientÚ_DocumentOutiÿÿÿi   €iþ?  é   é   ó    ó   ó    s     ó       s           s       ÿÿÿÿs   documents     s   updates     s   deletes     Ú	documentsÚupdatesÚdeletesÚops)ÚinsertÚupdateÚdeleteÚ	bulkWriteÚreplace)Úunicode_decode_error_handlerzCodecOptions[Mapping[str, Any]]Ú_UNICODE_REPLACE_CODEC_OPTIONSÚreturnÚintc                   C  s   t  tt¡S )z(Generate a pseudo random 32 bit integer.)ÚrandomÚrandintÚ	MIN_INT32Ú	MAX_INT32© rB   rB   ú^/var/www/html/Moveonwheels/move_on_wheels/venv/lib/python3.10/site-packages/pymongo/message.pyÚ_randintt   s   rD   ÚspecúMutableMapping[str, Any]Úread_preferencer!   c                 C  sD   |j }|j}|r |tjj kst|ƒdkr d| vrd| i} || d< | S )z-Add $readPreference to spec when appropriate.r+   ú$queryú$readPreference)ÚmodeÚdocumentr    ÚSECONDARY_PREFERREDÚlen)rE   rG   rJ   rK   rB   rB   rC   Ú_maybe_add_read_preferencey   s   rN   Ú	exceptionÚ	Exceptionúdict[str, Any]c                 C  s   t | ƒ| jjdœS )z<Convert an Exception into a failure document for publishing.)ÚerrmsgÚerrtype)ÚstrÚ	__class__Ú__name__©rO   rB   rB   rC   Ú_convert_exception‹   s   rX   c                 C  s   t | ƒ| j| jjdœS )zmConvert an Exception into a failure document for publishing,
    for use in client-level bulk write API.
    )rR   ÚcoderS   )rT   rY   rU   rV   rW   rB   rB   rC   Ú_convert_client_bulk_exception�   s   ýrZ   Ú	operationrT   ÚcommandúMapping[str, Any]Úresultc           	      C  s  |  dd¡}d|dœ}|  d|  dd¡¡}|rB|  d¡r'|d	dd
idœ|d< nd|  dd¡|dœ}d|v r;|d |d< |g|d< |S | dkrPt|d ƒ|d< |S | dkrŠd|v rdd|d dœg|d< |S |  d¡du rŠ|dkrŠ|d d }|d   d|d   d¡¡}d|dœg|d< |S )z6Convert a legacy write result to write command format.Únr   r+   )Úokr_   rR   ÚerrÚ Úwtimeouté@   T)rR   rY   ÚerrInfoÚwriteConcernErrorrY   é   )ÚindexrY   rR   re   ÚwriteErrorsr5   r1   r6   Úupserted)rh   Ú_idÚupdatedExistingFr2   Úurk   Úq)ÚgetrM   )	r[   r\   r^   ÚaffectedÚresrR   Úerrorr6   rk   rB   rB   rC   Ú_convert_write_result›   s.   


õ	úrs   rg   é   é    é€   )ÚtailableÚoplogReplayÚnoCursorTimeoutÚ	awaitDataÚallowPartialResultsÚfilterÚsortÚhintÚcommentÚmaxScanÚ	maxTimeMSÚmaxÚminÚ	returnKeyÚshowRecordIdÚsnapshot)rH   z$orderbyz$hintz$commentz$maxScanz
$maxTimeMSz$maxz$minz
$returnKeyz$showRecordIdz$showDiskLocz	$snapshotÚcollÚ
projectionú1Optional[Union[Mapping[str, Any], Iterable[str]]]ÚskipÚlimitÚ
batch_sizeúOptional[int]ÚoptionsÚread_concernr%   Ú	collationúOptional[Mapping[str, Any]]Úsessionú Optional[_AgnosticClientSession]Úallow_disk_useúOptional[bool]c                   s  d| i}d|v r'|  dd„ | ¡ D ƒ¡ d|v r| d¡ d|v r&| d¡ n||d< |r1||d< |r7||d	< |rGt|ƒ|d
< |dk rGd|d< |rU||krQ|d7 }||d< |jrb|	r]|	jsb|j|d< |rh||d< |
durp|
|d< ˆ r€|  ‡ fdd„t ¡ D ƒ¡ |S )z!Generate a find command document.ÚfindrH   c                 S  s,   g | ]\}}|t v rt | |fn||f‘qS rB   )Ú
_MODIFIERS)Ú.0ÚkeyÚvalrB   rB   rC   Ú
<listcomp>é   s    ÿÿz%_gen_find_command.<locals>.<listcomp>ú$explainrI   r|   rˆ   rŠ   r‹   r   TÚsingleBatchr+   Ú	batchSizeÚreadConcernr�   NÚallowDiskUsec                   s    g | ]\}}ˆ |@ r|d f‘qS )TrB   )r˜   Úoptrš   ©rŽ   rB   rC   r›   
  s     )r6   ÚitemsÚpopÚabsÚlevelÚin_transactionrK   Ú_OPTIONS)r‡   rE   rˆ   rŠ   r‹   rŒ   rŽ   r�   r�   r’   r”   ÚcmdrB   r¢   rC   Ú_gen_find_commandØ   sD   þÿ

€
rª   Ú	cursor_idÚmax_await_time_msúOptional[Any]Úconnr(   c                 C  sD   | |dœ}|r||d< |dur||d< |dur |j dkr ||d< |S )z$Generate a getMore command document.)ÚgetMoreÚ
collectionrž   Nr�   é	   r   )Úmax_wire_version)r«   r‡   rŒ   r¬   r   r®   r©   rB   rB   rC   Ú_gen_get_more_command  s   
	r³   z<iiiiiiBé   ÚdataÚbytesÚctxú.Union[SnappyContext, ZlibContext, ZstdContext]útuple[int, bytes]c                 C  s>   |  |¡}tƒ }ttt|ƒ |dd| t|ƒ|jƒ}||| fS )zDTakes message data, compresses it, and adds an OP_COMPRESSED header.r   iÜ  )ÚcompressrD   Ú_pack_compression_headerÚ_COMPRESSION_HEADER_SIZErM   Úcompressor_id)r[   rµ   r·   Ú
compressedÚ
request_idÚheaderrB   rB   rC   Ú	_compress&  s   

ù	rÁ   z<iiiic                 C  s(   t ƒ }tdt|ƒ |d| ƒ}||| fS )ztTakes message data and adds a message header based on the operation.

    Returns the resultant message string.
    rt   r   )rD   Ú_pack_headerrM   )r[   rµ   ÚridÚmessagerB   rB   rC   Ú__pack_message<  s   rÅ   z<iz<IBz<BÚflagsÚ
identifierÚdocsú!Optional[list[Mapping[str, Any]]]ÚoptsúCodecOptions[Any]útuple[bytes, int, int]c                   s¼   t |dˆ ƒ}t| dƒ}t|ƒ}d}|rR|durRtdƒ}	t|ƒ}
‡ fdd„|D ƒ}t|
ƒtdd„ |D ƒƒ d	 }t|ƒ}||7 }td
d„ |D ƒƒ}|||	||
g|¢}n||g}d |¡||fS )zäGet a OP_MSG message.

    Note: this method handles multiple documents in a type one payload but
    it does not perform batch splitting and the total message size is
    only checked *after* generating the entire message.
    Fr   Nr+   c                   s   g | ]}t |d ˆ ƒ‘qS ©F)r   ©r˜   Údoc©rÊ   rB   rC   r›   `  s    z%_op_msg_no_header.<locals>.<listcomp>c                 s  ó   � | ]}t |ƒV  qd S ©N©rM   rÎ   rB   rB   rC   Ú	<genexpr>a  ó   € z$_op_msg_no_header.<locals>.<genexpr>é   c                 s  rÑ   rÒ   rÓ   rÎ   rB   rB   rC   rÔ   d  rÕ   r-   )	r   Ú_pack_op_msg_flags_typerM   Ú
_pack_byter   ÚsumÚ	_pack_intr‚   Újoin)rÆ   r\   rÇ   rÈ   rÊ   ÚencodedÚ
flags_typeÚ
total_sizeÚmax_doc_sizeÚtype_oneÚcstringÚencoded_docsÚsizeÚencoded_sizerµ   rB   rÐ   rC   Ú_op_msg_no_headerK  s   
rå   útuple[int, bytes, int, int]c           
      C  s2   t | ||||ƒ\}}}td||ƒ\}	}|	|||fS )zInternal OP_MSG message helper.éÝ  )rå   rÁ   )
rÆ   r\   rÇ   rÈ   rÊ   r·   ÚmsgrÞ   Úmax_bson_sizerÃ   rB   rB   rC   Ú_op_msg_compressedk  s   	rê   c           
      C  s0   t | ||||ƒ\}}}td|ƒ\}}	||	||fS )z*Internal compressed OP_MSG message helper.rç   )rå   rÅ   )
rÆ   r\   rÇ   rÈ   rÊ   rµ   rÞ   ré   r¿   Ú
op_messagerB   rB   rC   Ú_op_msg_uncompressedy  s   rì   ÚdbnameúOptional[_ServerMode]ú4Union[SnappyContext, ZlibContext, ZstdContext, None]c           	   	   C  s¼   ||d< |durd|vr|j r|j|d< tt|ƒƒ}zt| }| |¡}W n ty2   d}d}Y nw z#|rGt| |||||ƒW |rF|||< S S t| ||||ƒW |rV|||< S S |r]|||< w )zGet a OP_MSG message.ú$dbNrI   rb   )	rJ   rK   ÚnextÚiterÚ
_FIELD_MAPr¤   ÚKeyErrorrê   rì   )	rÆ   r\   rí   rG   rÊ   r·   ÚnamerÇ   rÈ   rB   rB   rC   Ú_op_msgŠ  s.   	
þ
ÿý
ÿ
rö   Úcollection_nameÚnum_to_skipÚnum_to_returnÚqueryÚfield_selectorútuple[bytes, int]c           
      C  s`   t |d|ƒ}|rt |d|ƒ}nd}tt|ƒt|ƒƒ}	d t| ƒt |¡t|ƒt|ƒ||g¡|	fS )zGet an OP_QUERY message.Fr-   )r   r‚   rM   rÛ   rÚ   Úbsonr   )
rŽ   r÷   rø   rù   rú   rû   rÊ   rÜ   Úefsré   rB   rB   rC   Ú_query_implª  s    
úÿ
õrÿ   útuple[int, bytes, int]c                 C  s2   t | ||||||ƒ\}}	td||ƒ\}
}|
||	fS )z)Internal compressed query message helper.éÔ  )rÿ   rÁ   )rŽ   r÷   rø   rù   rú   rû   rÊ   r·   Úop_queryré   rÃ   rè   rB   rB   rC   Ú_query_compressedÉ  s
   ÿ
r  c                 C  s0   t | ||||||ƒ\}}td|ƒ\}	}
|	|
|fS )zInternal query message helper.r  )rÿ   rÅ   )rŽ   r÷   rø   rù   rú   rû   rÊ   r  ré   rÃ   rè   rB   rB   rC   Ú_query_uncompressedÛ  s
   
ÿ
r  c              	   C  s.   |rt | |||||||ƒS t| ||||||ƒS )zGet a **query** message.)r  r  )rŽ   r÷   rø   rù   rú   rû   rÊ   r·   rB   rB   rC   Ú_queryð  s   ÿÿr  z<qc                 C  s    d  tt | ¡t|ƒt|ƒg¡S )zGet an OP_GET_MORE message.r-   )rÛ   Ú_ZERO_32rý   r   rÚ   Ú_pack_long_long©r÷   rù   r«   rB   rB   rC   Ú_get_more_impl  s   üÿr	  c                 C  s   t dt| ||ƒ|ƒS )z+Internal compressed getMore message helper.éÕ  )rÁ   r	  ©r÷   rù   r«   r·   rB   rB   rC   Ú_get_more_compressed  s   r  c                 C  s   t dt| ||ƒƒS )z Internal getMore message helper.r
  )rÅ   r	  r  rB   rB   rC   Ú_get_more_uncompressed  s   r  c                 C  s   |r	t | |||ƒS t| ||ƒS )zGet a **getMore** message.)r  r  r  rB   rB   rC   Ú	_get_more(  s   r  s
   documents s   updates s   deletes c                   @  sj   e Zd ZdZ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
d*d"d#„Zd+d%d&„Zd'S ),Ú_BulkWriteContextBasez]Private base class for wrapping around AsyncConnection to use with write splitting functions.)Údb_namer®   Úop_idrõ   ÚfieldÚpublishÚ
start_timeÚ	listenersr’   rº   Úop_typeÚcodecÚdatabase_namerT   Úcmd_namer®   r(   Úoperation_idr=   r  r   r’   r“   r  r  rË   c	           	      C  s`   || _ || _|| _|| _|j| _|| _t| j | _t	j	 
¡ | _|| _t|jƒ| _|| _|| _d S rÒ   )r  r®   r  r  Úenabled_for_commandsr  rõ   ró   r  ÚdatetimeÚnowr  r’   ÚboolÚcompression_contextrº   r  r  ©	Úselfr  r  r®   r  r  r’   r  r  rB   rB   rC   Ú__init__P  s   
z_BulkWriteContextBase.__init__r<   c                 C  ó   | j jS )z#A proxy for SockInfo.max_bson_size.)r®   ré   ©r!  rB   rB   rC   ré   h  ó   z#_BulkWriteContextBase.max_bson_sizec                 C  s   | j r	| jjd S | jjS )z&A proxy for SockInfo.max_message_size.rt   )rº   r®   Úmax_message_sizer$  rB   rB   rC   r&  m  s   z&_BulkWriteContextBase.max_message_sizec                 C  r#  )z*A proxy for SockInfo.max_write_batch_size.)r®   Úmax_write_batch_sizer$  rB   rB   rC   r'  u  r%  z*_BulkWriteContextBase.max_write_batch_sizec                 C  ó   | j S )z:The maximum size of a BSON command before batch splitting.)ré   r$  rB   rB   rC   Úmax_split_sizez  ó   z$_BulkWriteContextBase.max_split_sizer¿   Úreplyr*   Údurationúdatetime.timedeltaÚNonec                 C  ó4   | j j||| j|| jj| jj| j| jj| jd�	 dS )z Publish a CommandSucceededEvent.©r  N)	r  Úpublish_command_successrõ   r®   ÚaddressÚserver_connection_idr  Ú
service_idr  )r!  r¿   r+  r,  rB   rB   rC   Ú_succeed  ó   
÷z_BulkWriteContextBase._succeedÚfailurec                 C  r/  )zPublish a CommandFailedEvent.r0  N)	r  Úpublish_command_failurerõ   r®   r2  r3  r  r4  r  )r!  r¿   r7  r,  rB   rB   rC   Ú_fail�  r6  z_BulkWriteContextBase._failN©r  rT   r  rT   r®   r(   r  r=   r  r   r’   r“   r  r=   r  rË   ©r<   r=   )r¿   r=   r+  r*   r,  r-  r<   r.  )r¿   r=   r7  r*   r,  r-  r<   r.  )rV   Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r"  Úpropertyré   r&  r'  r)  r5  r9  rB   rB   rB   rC   r  >  s    

r  c                      s:   e Zd ZdZdZd‡ fdd„Zddd„Zd dd„Z‡  ZS )!Ú_BulkWriteContextz]A wrapper around AsyncConnection/Connection for use with the collection-level bulk write API.rB   r  rT   r  r®   r(   r  r=   r  r   r’   r“   r  r  rË   c	           	   
     s   t ƒ  ||||||||¡ d S rÒ   ©Úsuperr"  r   ©rU   rB   rC   r"  ¡  s   øz_BulkWriteContext.__init__r©   rF   rÈ   úlist[Mapping[str, Any]]r<   úAtuple[int, Union[bytes, dict[str, Any]], list[Mapping[str, Any]]]c                 C  s<   | j d }t|| j||| j| ƒ\}}}|stdƒ‚|||fS )Nú.$cmdúcannot do an empty bulk write)r  Ú_do_batched_op_msgr  r  r   )r!  r©   rÈ   Ú	namespacer¿   rè   Úto_sendrB   rB   rC   Úbatch_command·  s   

ÿ
z_BulkWriteContext.batch_commandr¿   c              	   C  s6   ||| j < | j || j|| jj| jj| j| jj¡ |S )úPublish a CommandStartedEvent.)	r  r  Úpublish_command_startr  r®   r2  r3  r  r4  )r!  r©   r¿   rÈ   rB   rB   rC   Ú_startÂ  s   
ù	z_BulkWriteContext._startr:  )r©   rF   rÈ   rE  r<   rF  )r©   rF   r¿   r=   rÈ   rE  r<   rF   ©	rV   r<  r=  r>  r?  r"  rL  rO  Ú__classcell__rB   rB   rD  rC   rA  œ  s    
rA  c                   @  s(   e Zd ZdZddd	„Zeddd„ƒZdS )Ú_EncryptedBulkWriteContextrB   r©   rF   rÈ   rE  r<   ú3tuple[int, dict[str, Any], list[Mapping[str, Any]]]c                 C  s`   | j d }t|| j||| j| ƒ\}}|stdƒ‚| dd¡d }tt|ƒ|d … tƒ}d||fS )NrG  rH  r/   rÖ   r±   éÿÿÿÿ)	r  Ú_encode_batched_write_commandr  r  r   rh   r   Ú
memoryviewr   )r!  r©   rÈ   rJ  rè   rK  Ú	cmd_startÚoutgoingrB   rB   rC   rL  Ö  s   
ÿ
z(_EncryptedBulkWriteContext.batch_commandr=   c                 C  s   t S )z Reduce the batch splitting size.)Ú_MAX_SPLIT_SIZE_ENCr$  rB   rB   rC   r)  å  ó   z)_EncryptedBulkWriteContext.max_split_sizeN)r©   rF   rÈ   rE  r<   rS  r;  )rV   r<  r=  r?  rL  r@  r)  rB   rB   rB   rC   rR  Ó  s
    
rR  Údoc_sizeÚmax_sizer
   c                 C  s&   | dkrt d||f ƒ‚t | ›d�ƒ‚)z-Internal helper for raising DocumentTooLarge.r5   zfBSON document too large (%d bytes) - the connected server supports BSON document sizes up to %d bytes.z command document too large)r   )r[   r[  r\  rB   rB   rC   Ú_raise_document_too_largeë  s   ýÿ	r]  i    rE  Úackr  ÚbufÚ_BytesIOú#tuple[list[Mapping[str, Any]], int]c                 C  sd  |j }|j}|j}	|rdnd}
| |
¡ | d¡ | t|d|ƒ¡ | d¡ | ¡ }| d¡ z	| t|  ¡ W n tyE   tdƒd‚w g }d}|D ]O}t|d|ƒ}t	|ƒ}| ¡ | }|dkoe||	k}| ol||k}|sq|r�t
t ¡ ƒ|  }t|t	|ƒ|ƒ ||	kr‡ n| |¡ | |¡ |d	7 }||kr› nqL| ¡ }| |¡ | t|| ƒ¡ ||fS )
zCreate a batched OP_MSG write.r0   ó      r/   Fó   úUnknown commandNr   r+   )ré   r'  r&  Úwriter   ÚtellÚ_OP_MSG_MAPrô   r   rM   Úlistró   Úkeysr]  ÚappendÚseekrÚ   )r[   r\   rÈ   r^  rÊ   r·   r_  ré   r'  r&  rÆ   Úsize_locationrK  ÚidxrÏ   ÚvalueÚ
doc_lengthÚnew_message_sizeÚdoc_too_largeÚunacked_doc_too_largeÚwrite_opÚlengthrB   rB   rC   Ú_batched_op_msg_impl  sL   





ÿ

ÿ
ru  ú%tuple[bytes, list[Mapping[str, Any]]]c           	      C  ó*   t ƒ }t| ||||||ƒ\}}| ¡ |fS )zOEncode the next batched insert, update, or delete operation
    as OP_MSG.
    )r`  ru  Úgetvalue)	r[   r\   rÈ   r^  rÊ   r·   r_  rK  Ú_rB   rB   rC   Ú_encode_batched_op_msgE  s   rz  ú*tuple[int, bytes, list[Mapping[str, Any]]]c           
      C  sD   t | |||||ƒ\}}|jjdusJ ‚td||jjƒ\}}	||	|fS )z]Create the next batched insert, update, or delete operation
    with OP_MSG, compressed.
    Nrç   )rz  r®   r  rÁ   )
r[   r\   rÈ   r^  rÊ   r·   rµ   rK  r¿   rè   rB   rB   rC   Ú_batched_op_msg_compressedZ  s   
r|  c           
      C  sv   t ƒ }| t¡ | d¡ t| ||||||ƒ\}}| d¡ tƒ }	| t|	ƒ¡ | d¡ | t|ƒ¡ |	| ¡ |fS )z"OP_MSG implementation entry point.ó       Ý  rÖ   r   )r`  re  Ú_ZERO_64ru  rk  rD   rÚ   rx  )
r[   r\   rÈ   r^  rÊ   r·   r_  rK  rt  r¿   rB   rB   rC   Ú_batched_op_msgl  s   	



r  rJ  c                 C  sb   |   dd¡d |d< d|v rt|d  dd¡ƒ}nd}|jjr(t||||||ƒS t||||||ƒS )zRCreate the next batched insert, update, or delete operation
    using OP_MSG.
    Ú.r+   r   rð   ÚwriteConcernÚwT)Úsplitr  ro   r®   r  r|  r  )rJ  r[   r\   rÈ   rÊ   r·   r^  rB   rB   rC   rI  Œ  s   rI  c                      s:   e Zd ZdZdZd"‡ fdd„Zd#dd„Zd$d d!„Z‡  ZS )%Ú_ClientBulkWriteContextzYA wrapper around AsyncConnection/Connection for use with the client-level bulk write API.rB   r  rT   r  r®   r(   r  r=   r  r   r’   r“   r  rË   c              
     s   t ƒ  ||||||d|¡ d S )Nr   rB  )r!  r  r  r®   r  r  r’   r  rD  rB   rC   r"  ¦  s   
øz _ClientBulkWriteContext.__init__r©   rF   Ú
operationsú#list[tuple[str, Mapping[str, Any]]]Ú
namespacesú	list[str]r<   úZtuple[int, Union[bytes, dict[str, Any]], list[Mapping[str, Any]], list[Mapping[str, Any]]]c                 C  s2   t |||| j| ƒ\}}}}|stdƒ‚||||fS )NrH  )Ú_client_do_batched_op_msgr  r   )r!  r©   r…  r‡  r¿   rè   Úto_send_opsÚ
to_send_nsrB   rB   rC   rL  »  s   ÿz%_ClientBulkWriteContext.batch_commandr¿   Úop_docsrE  Úns_docsc              	   C  s<   ||d< ||d< | j  || j|| jj| jj| j| jj¡ |S )rM  r4   ÚnsInfo)r  rN  r  r®   r2  r3  r  r4  )r!  r©   r¿   r�  rŽ  rB   rB   rC   rO  È  s   ù	z_ClientBulkWriteContext._start)r  rT   r  rT   r®   r(   r  r=   r  r   r’   r“   r  rË   )r©   rF   r…  r†  r‡  rˆ  r<   r‰  )
r©   rF   r¿   r=   r�  rE  rŽ  rE  r<   rF   rP  rB   rB   rD  rC   r„  ¡  s    
r„  iè  Úcommand_encodedÚto_send_ops_encodedúlist[bytes]Úto_send_ns_encodedc                 C  sü   |rdnd}|  |¡ |  d¡ |  | ¡ |  d¡ | ¡ }|  d¡ |  d¡ |D ]}|  |¡ q*| ¡ }| ¡ }	| |¡ |  t|	| ƒ¡ | |¡ |  d¡ | ¡ }|  d¡ |  d¡ |D ]}
|  |
¡ qb| ¡ }	| |¡ |  t|	| ƒ¡ |	S )Nr0   rb  r/   rc  s   ops s   nsInfo )re  rf  rk  rÚ   )r�  r‘  r“  r^  r_  rÆ   rl  Ú
op_encodedÚresume_locationrt  Ú
ns_encodedrB   rB   rC   Ú_client_construct_op_msgá  s2   











r—  r…  r†  r‡  rˆ  ú<tuple[list[Mapping[str, Any]], list[Mapping[str, Any]], int]c           %        s`  ddd	„}|j }|j}	|j}
tˆ d
|ƒ}|s |dt|ƒ|t ƒ g d¢}ˆ  d¡r.| d¡ ˆ  d¡r8| d¡ ˆ  d¡rB| d¡ ‡ fdd„|D ƒ}tt|d
|ƒƒ}|
t|  }i }g }g }g }g }d}d}d}t	||ƒD ]´\\}}}|}|dkrŒ|sŒtt|d d
|ƒƒ}||||ƒ |dkr¤d}|s¤tt|d d
|ƒƒ}||||ƒ d}d}||vr¸d|i}t|ƒ}|||< || ||< t|d
|ƒ} t| ƒ}!|rÔt|d
|ƒ}"t|"ƒ}|sÞ|||!|t ƒ || |! | }#|#|krø|dkröt
||!|t ƒ  n+| |¡ | | ¡ ||!7 }|�r| |¡ | |"¡ ||7 }|d7 }||	k�r" nqnt|||||ƒ}$|||$fS )z:Create a batched OP_MSG write for client-level bulk write.r  rT   r[  r=   r‹   r<   r.  c                 S  s   ||krt | ||ƒ d S d S rÒ   )r]  )r  r[  r‹   rB   rB   rC   Ú_check_doc_size_limits  s   ÿz;_client_batched_op_msg_impl.<locals>._check_doc_size_limitsFr8   )r8   Ú
errorsOnlyÚorderedÚbypassDocumentValidationr   Úletc                   s   i | ]}|ˆ | “qS rB   rB   )r˜   r™   ©r\   rB   rC   Ú
<dictcomp>6  s    z/_client_batched_op_msg_impl.<locals>.<dictcomp>r   r5   rK   r9   r6   Ú
updateModsNÚnsr+   )r  rT   r[  r=   r‹   r=   r<   r.  )ré   r'  r&  r   rM   Ú_COMMAND_OVERHEADro   rj  Ú_OP_MSG_OVERHEADÚzipr]  r—  )%r\   r…  r‡  r^  rÊ   r·   r_  r™  ré   r'  r&  r�  Úabridged_keysÚcommand_abridgedÚcommand_len_abridgedÚmax_doc_sequences_bytesÚns_infor‹  rŒ  r‘  r“  Útotal_ops_lengthÚtotal_ns_lengthrm  Úreal_op_typeÚop_docrJ  r  r[  Úns_docÚ	ns_lengthÚnew_ns_indexÚop_doc_encodedÚ	op_lengthÚns_doc_encodedrp  rt  rB   rž  rC   Ú_client_batched_op_msg_impl  sŒ   











ÿ
ÿ
r´  ú>tuple[bytes, list[Mapping[str, Any]], list[Mapping[str, Any]]]c           
      C  s.   t ƒ }t| ||||||ƒ\}}}	| ¡ ||fS )zLEncode the next batched client-level bulkWrite
    operation as OP_MSG.
    )r`  r´  rx  )
r\   r…  r‡  r^  rÊ   r·   r_  r‹  rŒ  ry  rB   rB   rC   Ú_client_encode_batched_op_msg‡  s
   
ÿr¶  úCtuple[int, bytes, list[Mapping[str, Any]], list[Mapping[str, Any]]]c                 C  sH   t | |||||ƒ\}}}|jjdusJ ‚td||jjƒ\}	}
|	|
||fS )zZCreate the next batched client-level bulkWrite operation
    with OP_MSG, compressed.
    Nrç   )r¶  r®   r  rÁ   )r\   r…  r‡  r^  rÊ   r·   rµ   r‹  rŒ  r¿   rè   rB   rB   rC   Ú!_client_batched_op_msg_compressedš  s   
ÿr¸  c                 C  sz   t ƒ }| t¡ | d¡ t| ||||||ƒ\}}}	| d¡ tƒ }
| t|
ƒ¡ | d¡ | t|	ƒ¡ |
| ¡ ||fS )z=OP_MSG implementation entry point for client-level bulkWrite.r}  rÖ   r   )r`  re  r~  r´  rk  rD   rÚ   rx  )r\   r…  r‡  r^  rÊ   r·   r_  r‹  rŒ  rt  r¿   rB   rB   rC   Ú_client_batched_op_msg®  s   	


ÿ

r¹  c                 C  sV   d| d< d| v rt | d  dd¡ƒ}nd}|jjr"t| |||||ƒS t| |||||ƒS )zOCreate the next batched client-level bulkWrite
    operation using OP_MSG.
    Úadminrð   r�  r‚  r+   T)r  ro   r®   r  r¸  r¹  )r\   r…  r‡  rÊ   r·   r^  rB   rB   rC   rŠ  Ì  s   
rŠ  c           	      C  rw  )z:Encode the next batched insert, update, or delete command.)r`  Ú_batched_write_command_implrx  )	rJ  r[   r\   rÈ   rÊ   r·   r_  rK  ry  rB   rB   rC   rU  ã  s   	rU  c                 C  sÐ  |j }|j}|t }	|j}
| t¡ | |  d¡¡ | t¡ | t¡ | 	¡ }| t
 |¡¡ | dd¡ | ¡  z	| t| ¡ W n tyO   tdƒd‚w | 	¡ d }g }d}|D ]`}t|ƒ d¡}t|d|ƒ}t|ƒ|	k}|rƒtt ¡ ƒ| }t|t|ƒ|ƒ |d	ko”| 	¡ t|ƒ t|ƒ |
k}||k}|s�|rŸ n| t¡ | |¡ | t¡ | |¡ | |¡ |d	7 }q\| t¡ | 	¡ }| |¡ | t|| d	 ƒ¡ | |¡ | t|| ƒ¡ ||fS )
z(Create a batched OP_QUERY write command.Úutf8rT  r,   rd  NrÖ   r   Fr+   )ré   r'  r¢  r)  re  r  ÚencodeÚ_ZERO_8Ú_SKIPLIMrf  rý   rk  ÚtruncateÚ_OP_MAPrô   r   rT   r   rM   rh  ró   ri  r]  Ú_BSONOBJrj  Ú_ZERO_16rÚ   )rJ  r[   r\   rÈ   rÊ   r·   r_  ré   r'  Úmax_cmd_sizer)  Úcommand_startÚ
list_startrK  rm  rÏ   r™   rn  rq  rs  Úenough_dataÚenough_documentsrt  rB   rB   rC   r»  ö  sX   




ÿ$








r»  c                   @  s€   e Zd ZdZdZe d¡jZdZ	d(dd„Z
	d)d*dd„Zdeddfd+dd„Zd,dd„Zd-d!d"„Zed.d#d$„ƒZed/d&d'„ƒZdS )0Ú_OpReplyz$A MongoDB OP_REPLY response message.)rÆ   r«   Únumber_returnedr1   z<iqiir+   rÆ   r=   r«   rÊ  r1   úbytes | memoryviewc                 C  s    || _ t|ƒ| _|| _|| _d S rÒ   )rÆ   r   r«   rÊ  r1   )r!  rÆ   r«   rÊ  r1   rB   rB   rC   r"  K  s   

z_OpReply.__init__Nr�   Úuser_fieldsr‘   r<   úlist[bytes | memoryview]c                 C  sÚ   | j d@ r|du rtdƒ‚d|f }d|ddœ}t|d|ƒ‚| j d@ rdt | j¡ ¡ }| d	d¡ |d
  t	j
¡r@t|d
 |ƒ‚| d¡dkrVd}t| d
|¡| d¡|ƒ‚td| d
¡ | d¡|ƒ‚| jrk| jgS g S )aœ  Check the response header from the database, without decoding BSON.

        Check the response for errors and unpack.

        Can raise CursorNotFound, NotPrimaryError, ExecutionTimeout, or
        OperationFailure.

        :param cursor_id: cursor_id we sent to get this response -
            used for raising an informative exception when we get cursor id not
            valid at server response.
        r+   Nz"No cursor id for getMore operationzCursor not found, cursor id: %dr   é+   )r`   rR   rY   r,   r`   z$errrY   é2   zoperation exceeded time limitzdatabase error: %s)rÆ   r   r   rý   ÚBSONr1   ÚdecodeÚ
setdefaultÚ
startswithr   ÚLEGACY_ERRORr   ro   r   r   )r!  r«   rÌ  rè   ÚerrobjÚerror_objectÚdefault_msgrB   rB   rC   Úraw_responseS  s0   


ÿýz_OpReply.raw_responseFÚcodec_optionsrË   Úlegacy_responser  úlist[dict[str, Any]]c                 C  s,   |   |¡ |rt | j|¡S t | j||¡S )aè  Unpack a response from the database and decode the BSON document(s).

        Check the response for errors and unpack, returning a dictionary
        containing the response data.

        Can raise CursorNotFound, NotPrimaryError, ExecutionTimeout, or
        OperationFailure.

        :param cursor_id: cursor_id we sent to get this response -
            used for raising an informative exception when we get cursor id not
            valid at server response
        :param codec_options: an instance of
            :class:`~bson.codec_options.CodecOptions`
        :param user_fields: Response fields that should be decoded
            using the TypeDecoders from codec_options, passed to
            bson._decode_all_selective.
        )rØ  rý   Ú
decode_allr1   Ú_decode_all_selective©r!  r«   rÙ  rÌ  rÚ  rB   rB   rC   Úunpack_response  s   
z_OpReply.unpack_responserQ   c                 C  s"   | j |d�}| jdksJ ‚|d S )úUnpack a command response.©rÙ  r+   r   )rß  rÊ  )r!  rÙ  rÈ   rB   rB   rC   Úcommand_responseœ  s   z_OpReply.command_responser
   c                 C  s   t ‚©z)Return the bytes of the command response.)ÚNotImplementedErrorr$  rB   rB   rC   Úraw_command_response¢  rZ  z_OpReply.raw_command_responsec                 C  s   dS )ú+Is the moreToCome bit set on this response?FrB   r$  rB   rB   rC   Úmore_to_come§  rZ  z_OpReply.more_to_comerè   c                 C  s,   |   |¡\}}}}|dd… }| ||||ƒS )z%Construct an _OpReply from raw bytes.é   N)ÚUNPACK_FROM)Úclsrè   rÆ   r«   ry  rÊ  r1   rB   rB   rC   Úunpack¬  s   z_OpReply.unpack)rÆ   r=   r«   r=   rÊ  r=   r1   rË  )NN)r«   r�   rÌ  r‘   r<   rÍ  ©
r«   r�   rÙ  rË   rÌ  r‘   rÚ  r  r<   rÛ  ©rÙ  rË   r<   rQ   )r<   r
   ©r<   r  )rè   rË  r<   rÉ  )rV   r<  r=  r>  r?  ÚstructÚStructÚunpack_fromré  ÚOP_CODEr"  rØ  r;   rß  râ  rå  r@  rç  Úclassmethodrë  rB   rB   rB   rC   rÉ  C  s&    
	ÿ.û

rÉ  c                   @  sŽ   e Zd ZdZdZe d¡jZdZ	dZ
dZdZd)dd„Zdi fd*dd„Zdeddfd+dd„Zd,d d!„Zd-d"d#„Zed.d$d%„ƒZed/d'd(„ƒZdS )0Ú_OpMsgz"A MongoDB OP_MSG response message.)rÆ   r«   rÊ  Úpayload_documentz<IBirç   r+   r,   i   rÆ   r=   rõ  rË  c                 C  s   || _ || _d S rÒ   )rÆ   rõ  )r!  rÆ   rõ  rB   rB   rC   r"  Ã  s   
z_OpMsg.__init__Nr«   r�   rÌ  r‘   r<   rE  c                 C  s   t  t| jƒ|t¡}|gS )zp
        cursor_id is ignored
        user_fields is used to determine which fields must not be decoded
        )rý   Ú_decode_selectiver   rõ  r   )r!  r«   rÌ  Úinflated_responserB   rB   rC   rØ  Ç  s   	ÿz_OpMsg.raw_responseFrÙ  rË   rÚ  r  rÛ  c                 C  s   |rJ ‚t  | j||¡S )a~  Unpack a OP_MSG command response.

        :param cursor_id: Ignored, for compatibility with _OpReply.
        :param codec_options: an instance of
            :class:`~bson.codec_options.CodecOptions`
        :param user_fields: Response fields that should be decoded
            using the TypeDecoders from codec_options, passed to
            bson._decode_all_selective.
        )rý   rÝ  rõ  rÞ  rB   rB   rC   rß  Õ  s   z_OpMsg.unpack_responserQ   c                 C  s   | j |d�d S )rà  rá  r   )rß  )r!  rÙ  rB   rB   rC   râ  é  s   z_OpMsg.command_responsec                 C  r(  rã  )rõ  r$  rB   rB   rC   rå  í  s   z_OpMsg.raw_command_responsec                 C  s   t | j| j@ ƒS )ræ  )r  rÆ   ÚMORE_TO_COMEr$  rB   rB   rC   rç  ñ  s   z_OpMsg.more_to_comerè   c                 C  s’   |   |¡\}}}|dkr&|| j@ rtd|d›�ƒ‚|| jA r&td|d›�ƒ‚|dkr2td|d›�ƒ‚t|ƒ|d kr>tdƒ‚|dd… }| ||ƒS )	z#Construct an _OpMsg from raw bytes.r   z+Unsupported OP_MSG flag checksumPresent: 0xÚxzUnsupported OP_MSG flags: 0xz#Unsupported OP_MSG payload type: 0xé   z$Unsupported OP_MSG reply: >1 sectionN)ré  ÚCHECKSUM_PRESENTr   rø  rM   )rê  rè   rÆ   Úfirst_payload_typeÚfirst_payload_sizerõ  rB   rB   rC   rë  ö  s   


z_OpMsg.unpack)rÆ   r=   rõ  rË  )r«   r�   rÌ  r‘   r<   rE  rì  rí  )r<   rË  rî  )rè   rË  r<   rô  )rV   r<  r=  r>  r?  rï  rð  rñ  ré  rò  rû  rø  ÚEXHAUST_ALLOWEDr"  rØ  r;   rß  râ  rå  r@  rç  ró  rë  rB   rB   rB   rC   rô  ¶  s.    
ýû

rô  zBdict[int, Callable[[bytes | memoryview], Union[_OpReply, _OpMsg]]]Ú_UNPACK_REPLYc                   @  sj   e Zd ZdZdZdZdZd8dd „Zd9d#d$„Zd:d%d&„Z	d;d)d*„Z
d<d-d.„Z	/d=d>d2d3„Z	/d=d?d6d7„ZdS )@Ú_QueryzA query operation.)rÆ   Údbr‡   ÚntoskiprE   ÚfieldsrÙ  rG   r‹   rŒ   rõ   r�   r�   r’   Úclientr”   Ú_as_commandÚexhaustNrÆ   r=   r  rT   r‡   r  rE   r]   r  r‘   rÙ  rË   rG   r!   r‹   rŒ   r�   r%   r�   r’   r“   r  r)   r”   r•   r  r  c                 C  sp   || _ || _|| _|| _|| _|| _|| _|| _|| _|	| _	|
| _
|| _|| _|| _|| _d| _d | _|| _d S )Nr–   )rÆ   r  r‡   r  rE   r  rÙ  rG   r�   r‹   rŒ   r�   r’   r  r”   rõ   r  r  )r!  rÆ   r  r‡   r  rE   r  rÙ  rG   r‹   rŒ   r�   r�   r’   r  r”   r  rB   rB   rC   r"  ,  s$   
z_Query.__init__r<   r.  c                 C  ó
   d | _ d S rÒ   ©r  r$  rB   rB   rC   ÚresetR  ó   
z_Query.resetc                 C  ó   | j › d| j› �S ©Nr€  ©r  r‡   r$  rB   rB   rC   rJ  U  ó   z_Query.namespacer®   r(   c                 C  sR   d}| j sd}n|jdkrd}n| jjstd| jj|jf ƒ‚| | j| j¡ |S )NFTrg   zDread concern level of %s is not valid with a max wire version of %d.)	r  r²   r�   Úok_for_legacyr   r¦   Úvalidate_sessionr  r’   )r!  r®   Úuse_find_cmdrB   rB   rC   Úuse_commandX  s   
ÿÿz_Query.use_commandr©   rQ   c                 C  ó   || j f| _d S rÒ   ©r  r  ©r!  r©   rB   rB   rC   Úupdate_commandh  ó   z_Query.update_commandFÚapply_timeoutútuple[dict[str, Any], str]c                 C  sÔ   | j dur| j S d| jv }t| j| j| j| j| j| j| j| j	| j
| j| jƒ}|r/d| _d|i}| |¡ | jrN| j |d| j|¡ |sN| jjsN| j ||¡ | || j| j¡ |ra|j| j|d� || jf| _ | j S )z.Return a find command document for this query.Nrœ   ÚexplainF©r©   )r  rE   rª   r‡   r  r  r‹   rŒ   rÆ   r�   r�   r’   r”   rõ   Úadd_server_apiÚ	_apply_torG   r§   Ú_update_read_concernÚsend_cluster_timer  r  r  )r!  r®   r  r  r©   rB   rB   rC   Ú
as_commandk  s:   

õ
z_Query.as_commandÚuse_cmdr   c              
   C  sâ   || _ |jr| jdB }n| j}|  ¡ }| j}|r5|  |¡d }td|| j|| j|j	d�\}}}	}
|||	fS | j
dkr<dp>| j
}| jrN|rKt| j|ƒ}n| j}|jr]t|tƒsXJ ‚t||ƒ}t||| j|||rhdn| j| j|j	d�S )z:Get a query message, possibly setting the secondaryOk bit.rÖ   r   ©r·   r+   r,   N)rG   rJ   rÆ   rJ  rE   r   rö   r  rÙ  r  rŒ   r‹   rƒ   Ú	is_mongosÚ
isinstancer	   rN   r  r  r  )r!  rG   r®   r!  rÆ   r¡  rE   r¿   rè   rã   ry  Ú	ntoreturnrB   rB   rC   Úget_message’  sF   ú

øz_Query.get_message) rÆ   r=   r  rT   r‡   rT   r  r=   rE   r]   r  r‘   rÙ  rË   rG   r!   r‹   r=   rŒ   r=   r�   r%   r�   r‘   r’   r“   r  r)   r”   r•   r  r  ©r<   r.  ©r<   rT   ©r®   r(   r<   r  ©r©   rQ   r<   r.  rÍ   ©r®   r(   r  r  r<   r  )rG   r!   r®   r(   r!  r  r<   r   )rV   r<  r=  r>  r?  Úconn_mgrr«   r"  r	  rJ  r  r  r   r&  rB   rB   rB   rC   r     s    

&


ÿ(ÿr   c                   @  sf   e Zd ZdZdZdZd4dd„Zd5dd„Zd6dd „Zd7d#d$„Z	d8d'd(„Z
	)d9d:d,d-„Z	)d9d;d1d2„Zd3S )<Ú_GetMorezA getmore operation.)r  r‡   r%  r«   r¬   rÙ  rG   r’   r  r,  r  r  r   r¯   r  rT   r‡   r%  r=   r«   rÙ  rË   rG   r!   r’   r“   r  r)   r¬   r�   r,  r   r  r  r   c                 C  sR   || _ || _|| _|| _|| _|| _|| _|| _|	| _|
| _	d | _
|| _|| _d S rÒ   )r  r‡   r%  r«   rÙ  rG   r’   r  r¬   r,  r  r  r   )r!  r  r‡   r%  r«   rÙ  rG   r’   r  r¬   r,  r  r   rB   rB   rC   r"  Ü  s   
z_GetMore.__init__r<   r.  c                 C  r  rÒ   r  r$  rB   rB   rC   r	  ù  r
  z_GetMore.resetc                 C  r  r  r  r$  rB   rB   rC   rJ  ü  r  z_GetMore.namespacer®   r(   c                 C  s2   d}| j sd}n|jdkrd}| | j| j¡ |S )NFTrg   )r  r²   r  r  r’   )r!  r®   r!  rB   rB   rC   r  ÿ  s   
z_GetMore.use_commandr©   rQ   c                 C  r  rÒ   r  r  rB   rB   rC   r  
  r  z_GetMore.update_commandFr  r  c                 C  sˆ   | j dur| j S t| j| j| j| j| j|ƒ}| jr#| j |d| j	|¡ | 
|¡ | || j| j¡ |r;|j| jdd� || jf| _ | j S )z1Return a getMore command document for this query.NFr  )r  r³   r«   r‡   r%  r¬   r   r’   r  rG   r  r  r  r  r  )r!  r®   r  r©   rB   rB   rC   r     s$   
ú
z_GetMore.as_commandÚdummy0r!  ú0Union[tuple[int, bytes, int], tuple[int, bytes]]c                 C  sv   |   ¡ }|j}|r2|  |¡d }| jr| jrtj}nd}t||| jd| j	|jd�\}}	}
}||	|
fS t
|| j| j|ƒS )zGet a getmore message.r   Nr"  )rJ  r  r   r,  r  rô  rþ  rö   r  rÙ  r  r%  r«   )r!  r.  r®   r!  r¡  r·   rE   rÆ   r¿   rè   rã   ry  rB   rB   rC   r&  '  s   ÿ
z_GetMore.get_messageN)r  rT   r‡   rT   r%  r=   r«   r=   rÙ  rË   rG   r!   r’   r“   r  r)   r¬   r�   r,  r   r  r  r   r   r'  r(  r)  r*  rÍ   r+  )r.  r   r®   r(   r!  r  r<   r/  )rV   r<  r=  r>  r?  rõ   r"  r	  rJ  r  r  r   r&  rB   rB   rB   rC   r-  Ç  s    




ÿÿr-  c                      ó   e Zd Zd‡ fdd„Z‡  ZS )Ú_RawBatchQueryr®   r(   r<   r  c                   ó(   t ƒ  |¡ |jdkrdS | jsdS dS ©Nrg   TF©rC  r  r²   r  ©r!  r®   rD  rB   rC   r  =  ó   
z_RawBatchQuery.use_commandr)  ©rV   r<  r=  r  rQ  rB   rB   rD  rC   r1  <  ó    r1  c                      r0  )Ú_RawBatchGetMorer®   r(   r<   r  c                   r2  r3  r4  r5  rD  rB   rC   r  I  r6  z_RawBatchGetMore.use_commandr)  r7  rB   rB   rD  rC   r9  H  r8  r9  c                   @  sP   e Zd ZU dZded< dd	d
„Zeddd„ƒZddd„Zddd„Z	ddd„Z
dS )Ú_CursorAddresszEThe server address (host, port) of a cursor, with namespace property.r   Ú_CursorAddress__namespacer2  r&   rJ  rT   r<   c                 C  s   t  | |¡}||_|S rÒ   )ÚtupleÚ__new__r;  )rê  r2  rJ  r!  rB   rB   rC   r=  Y  s   z_CursorAddress.__new__c                 C  r(  )zThe namespace this cursor.)r;  r$  rB   rB   rC   rJ  ^  r*  z_CursorAddress.namespacer=   c                 C  s   g | ¢| j ‘R  ¡ S rÒ   )r;  Ú__hash__r$  rB   rB   rC   r>  c  s   z_CursorAddress.__hash__ÚotherÚobjectr  c                 C  s*   t |tƒrt| ƒt|ƒko| j|jkS tS rÒ   )r$  r:  r<  rJ  ÚNotImplemented©r!  r?  rB   rB   rC   Ú__eq__h  s   
z_CursorAddress.__eq__c                 C  s
   | |k S rÒ   rB   rB  rB   rB   rC   Ú__ne__m  r
  z_CursorAddress.__ne__N)r2  r&   rJ  rT   r<   r:  r(  r;  )r?  r@  r<   r  )rV   r<  r=  r>  Ú__annotations__r=  r@  rJ  r>  rC  rD  rB   rB   rB   rC   r:  T  s   
 


r:  .r;  )rE   rF   rG   r!   r<   rF   )rO   rP   r<   rQ   )r[   rT   r\   r]   r^   r]   r<   rQ   )NNN)r‡   rT   rE   r]   rˆ   r‰   rŠ   r=   r‹   r=   rŒ   r�   rŽ   r�   r�   r%   r�   r‘   r’   r“   r”   r•   r<   rQ   )r«   r�   r‡   rT   rŒ   r�   r¬   r�   r   r­   r®   r(   r<   rQ   )r[   r=   rµ   r¶   r·   r¸   r<   r¹   )r[   r=   rµ   r¶   r<   r¹   )rÆ   r=   r\   r]   rÇ   rT   rÈ   rÉ   rÊ   rË   r<   rÌ   )rÆ   r=   r\   r]   rÇ   rT   rÈ   rÉ   rÊ   rË   r·   r¸   r<   ræ   )rÆ   r=   r\   r]   rÇ   rT   rÈ   rÉ   rÊ   rË   r<   ræ   rÒ   )rÆ   r=   r\   rF   rí   rT   rG   rî   rÊ   rË   r·   rï   r<   ræ   )rŽ   r=   r÷   rT   rø   r=   rù   r=   rú   r]   rû   r‘   rÊ   rË   r<   rü   )rŽ   r=   r÷   rT   rø   r=   rù   r=   rú   r]   rû   r‘   rÊ   rË   r·   r¸   r<   r   )rŽ   r=   r÷   rT   rø   r=   rù   r=   rú   r]   rû   r‘   rÊ   rË   r<   r   )rŽ   r=   r÷   rT   rø   r=   rù   r=   rú   r]   rû   r‘   rÊ   rË   r·   rï   r<   r   )r÷   rT   rù   r=   r«   r=   r<   r¶   )
r÷   rT   rù   r=   r«   r=   r·   r¸   r<   r¹   )r÷   rT   rù   r=   r«   r=   r<   r¹   )
r÷   rT   rù   r=   r«   r=   r·   rï   r<   r¹   )r[   rT   r[  r=   r\  r=   r<   r
   )r[   r=   r\   r]   rÈ   rE  r^  r  rÊ   rË   r·   rA  r_  r`  r<   ra  )r[   r=   r\   r]   rÈ   rE  r^  r  rÊ   rË   r·   rA  r<   rv  )r[   r=   r\   r]   rÈ   rE  r^  r  rÊ   rË   r·   rA  r<   r{  )rJ  rT   r[   r=   r\   rF   rÈ   rE  rÊ   rË   r·   rA  r<   r{  )r�  r¶   r‘  r’  r“  r’  r^  r  r_  r`  r<   r=   )r\   r]   r…  r†  r‡  rˆ  r^  r  rÊ   rË   r·   r„  r_  r`  r<   r˜  )r\   r]   r…  r†  r‡  rˆ  r^  r  rÊ   rË   r·   r„  r<   rµ  )r\   r]   r…  r†  r‡  rˆ  r^  r  rÊ   rË   r·   r„  r<   r·  )r\   rF   r…  r†  r‡  rˆ  rÊ   rË   r·   r„  r<   r·  )rJ  rT   r[   r=   r\   rF   rÈ   rE  rÊ   rË   r·   rA  r<   rv  )rJ  rT   r[   r=   r\   rF   rÈ   rE  rÊ   rË   r·   rA  r_  r`  r<   ra  )‘r>  Ú
__future__r   r  r>   rï  Úior   r`  Útypingr   r   r   r   r   r	   r
   r   r   rý   r   r   r   Ú
bson.int64r   Úbson.raw_bsonr   r   r   r   Úpymongo.hellor   Úpymongo.monitoringr   Úpymongor   Ú_use_cÚImportErrorÚpymongo.errorsr   r   r   r   r   r   r   r   Úpymongo.read_preferencesr    r!   Úpymongo.compression_supportr"   r#   r$   Úpymongo.read_concernr%   Úpymongo.typingsr&   r'   r(   r)   r*   rA   r@   r¢  Ú_INSERTÚ_UPDATEÚ_DELETEÚ_EMPTYrÂ  r¾  rÃ  r  r~  r¿  rÁ  ró   r;   rE  rD   rN   rX   rZ   rs   r¨   r—   rª   r³   rð  Úpackr»   r¼   rÁ   rÂ   rÅ   rÚ   r×   rØ   rå   rê   rì   rö   rÿ   r  r  Ú_query_messager  r  r	  r  r  Ú_get_more_messager  rg  r  rA  rR  r]  rY  ru  rz  r|  r  rI  r„  r£  r—  r´  r¶  r¸  r¹  rŠ  rU  r»  rÉ  rô  rò  rë  rÿ  r   r-  r1  r9  r<  r:  rB   rB   rB   rC   Ú<module>   s,  ,ÿ(
	ýüÿ




%û
ôõ
7

 	ú ø
üý^7D=0vMsUþ 8u