o
    Åîï]é  ã                   @   sŒ  d Z ddlZddlZddlZddlZddlmZmZmZmZm	Z	 ddl
mZ ddlmZmZ ddlmZmZ ddlmZ z
ddlmZ d	ZW n eyQ   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!m"Z" ddl#m$Z$ ddl%m&Z& dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3e*de+de,diZ4ddd d!œZ5d"Z6ed#d$�Z7d%d&„ Z8d'd(„ Z9d)d*„ Z:d+d,„ Z;eg d-¢ƒZ<eg d.¢ƒZ=	d¤d/d0„Z>d1d2„ Z?G d3d4„ d4e@ƒZAG d5d6„ d6e@ƒZBG d7d8„ d8eAƒZCG d9d:„ d:eBƒZDG d;d<„ d<eEƒZFe Gd=¡jHZId>ZJd?d@„ ZKdAdB„ ZLe GdC¡jHZMdDdE„ ZNe GdF¡jHZOdGdH„ ZPdIdJ„ ZQdKdL„ ZRe�r'ejSZR	d¥dMdN„ZTdOdP„ ZUdQdR„ ZVdSdT„ ZWe�r?ejXZW	d¥dUdV„ZYe GdW¡jHZZe GdX¡jHZ[dYdZ„ Z\d[d\„ Z]d]d^„ Z^e�rcej_Z^	d¥d_d`„Z_dadb„ Z`	d¦dcdd„Za	
d§dedf„Zbe�rejcZb	d¦dgdh„Zde Gdi¡jHZedjdk„ Zfdldm„ Zgdndo„ Zhe�r�ejiZhd¥dpdq„Zjdrds„ Zkdtdu„ Zl	d¨dvdw„Zm	d©dxdy„Zndzd{„ ZoG d|d}„ d}e@ƒZpd~ZqG dd€„ d€epƒZrd�d‚„ Zsdƒd„„ Zte�rÚejtZte*d…e+d†e,d‡iZudˆd‰„ ZvdŠd‹„ Zwe�rðejwZwdŒd�„ ZxdŽd�„ Zye�rþejyZyd�d‘„ Zzd’d“„ Z{d”d•„ Z|e�rej|Z|d–d—„ Z}e�rej}Z}d˜d™„ Z~dšd›„ Zdœd�„ Z€G dždŸ„ dŸe@ƒZ�G d d¡„ d¡e@ƒZ‚e�jƒe�j„e‚jƒe‚j„iZ…d¢d£„ Z†dS )ªzÕTools for creating `messages
<http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol>`_ to be sent to
MongoDB.

.. note:: This module is for internal use and is generally not needed by
   application developers.
é    N)ÚCodecOptionsÚdecodeÚencodeÚ_dict_to_bsonÚ_make_c_string)ÚDEFAULT_CODEC_OPTIONS)Ú_inflate_bsonÚDEFAULT_RAW_BSON_OPTIONS)ÚbÚStringIO©ÚSON)Ú	_cmessageTF)ÚConfigurationErrorÚCursorNotFoundÚDocumentTooLargeÚExecutionTimeoutÚInvalidOperationÚNotMasterErrorÚOperationFailureÚProtocolError)ÚDEFAULT_READ_CONCERN)ÚReadPreference)ÚWriteConcerniÿÿÿi   €iþ?  é   é   ó    ó   ó    s     ó       s           s       ÿÿÿÿs   documents     s   updates     s   deletes     Ú	documentsÚupdatesÚdeletes)ÚinsertÚupdateÚdeleteú%s.%sÚreplace)Úunicode_decode_error_handlerc                   C   s   t  tt¡S )z(Generate a pseudo random 32 bit integer.)ÚrandomÚrandintÚ	MIN_INT32Ú	MAX_INT32© r-   r-   úA/var/www/html/env/lib/python3.10/site-packages/pymongo/message.pyÚ_randintZ   ó   r/   c                 C   sX   |j }|j}|j}|r*|tjj ks|i gks|dkr*d| vr%td| fgƒ} |j| d< | S )z-Add $readPreference to spec when appropriate.éÿÿÿÿú$queryú$readPreference)ÚmodeÚtag_setsÚmax_stalenessr   ÚSECONDARY_PREFERREDr   Údocument)ÚspecÚread_preferencer4   r5   r6   r-   r-   r.   Ú_maybe_add_read_preference_   s   

r;   c                 C   s   t | ƒ| jjdœS )z<Convert an Exception into a failure document for publishing.)ÚerrmsgÚerrtype)ÚstrÚ	__class__Ú__name__)Ú	exceptionr-   r-   r.   Ú_convert_exceptiont   s   ÿrB   c           	      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 )z7Convert a legacy write result to write commmand format.Únr   r   )ÚokrC   r<   ÚerrÚ Úwtimeouté@   T)r<   ÚcodeÚerrInfoÚwriteConcernErrorrI   é   )ÚindexrI   r<   rJ   ÚwriteErrorsr#   r    r$   Úupserted)rM   Ú_idÚupdatedExistingFr!   ÚurP   Úq)ÚgetÚlen)	Ú	operationÚcommandÚresultÚaffectedÚresr<   Úerrorr$   rP   r-   r-   r.   Ú_convert_write_resultz   s:   

þ
þ
õ	úr\   ))Útailabler   )ÚoplogReplayrL   )ÚnoCursorTimeouté   )Ú	awaitDataé    )ÚallowPartialResultsé€   ))r2   Úfilter)z$orderbyÚsort)z$hintÚhint)z$commentÚcomment)z$maxScanÚmaxScan)z
$maxTimeMSÚ	maxTimeMS)z$maxÚmax)z$minÚmin)z
$returnKeyÚ	returnKey)z$showRecordIdÚshowRecordId)z$showDiskLocrn   )z	$snapshotÚsnapshotc
                    sê   t d| fgƒ}
d|v r*|
 dd„ | ¡ D ƒ¡ d|
v r |
 d¡ d|
v r)|
 d¡ n||
d< |r4||
d< |r:||
d	< |rJt|ƒ|
d
< |dk rJd|
d< |rP||
d< |jr]|	rX|	js]|j|
d< |rc||
d< ˆ rs|
 ‡ fdd„t ¡ D ƒ¡ |
S )z!Generate a find command document.Úfindr2   c                 S   s,   g | ]\}}|t v rt | |fn||f‘qS r-   )Ú
_MODIFIERS)Ú.0ÚkeyÚvalr-   r-   r.   Ú
<listcomp>½   s     ÿz%_gen_find_command.<locals>.<listcomp>ú$explainr3   re   Ú
projectionÚskipÚlimitr   TÚsingleBatchÚ	batchSizeÚreadConcernÚ	collationc                    s    g | ]\}}ˆ |@ r|d f‘qS )Tr-   )rr   Úoptrt   ©Úoptionsr-   r.   ru   Õ   s    þ)	r   r$   ÚitemsÚpopÚabsÚlevelÚin_transactionr8   Ú_OPTIONS)Úcollr9   rw   rx   ry   Ú
batch_sizer€   Úread_concernr}   ÚsessionÚcmdr-   r   r.   Ú_gen_find_command¸   s<   
ÿ

€
ÿrŒ   c                 C   s4   t d| fd|fgƒ}|r||d< |dur||d< |S )z$Generate a getMore command document.ÚgetMoreÚ
collectionr{   Nrj   r   )Ú	cursor_idr‡   rˆ   Úmax_await_time_msr‹   r-   r-   r.   Ú_gen_get_more_commandÛ   s   ÿr‘   c                   @   sF   e Zd ZdZdZdZdZdd„ Zdd„ Zdd	„ Z	d
d„ Z
ddd„ZdS )Ú_QueryzA query operation.)ÚflagsÚdbr‡   Úntoskipr9   ÚfieldsÚcodec_optionsr:   ry   rˆ   Únamer‰   r}   rŠ   ÚclientÚ_as_commandNc                 C   sd   || _ || _|| _|| _|| _|| _|| _|| _|| _|	| _	|
| _
|| _|| _|| _d| _d | _d S )Nrp   )r“   r”   r‡   r•   r9   r–   r—   r:   r‰   ry   rˆ   r}   rŠ   r™   r˜   rš   )Úselfr“   r”   r‡   r•   r9   r–   r—   r:   ry   rˆ   r‰   r}   rŠ   r™   r-   r-   r.   Ú__init__ò   s    
z_Query.__init__c                 C   ó   t | j| jf S ©N©Ú_UJOINr”   r‡   ©r›   r-   r-   r.   Ú	namespace  ó   z_Query.namespacec                 C   sn   d}|j dkr|sd}n| jjstd| jj|j f ƒ‚|j dk r-| jd ur-td|j f ƒ‚| | j| j¡ |S )NFé   TzDread concern level of %s is not valid with a max wire version of %d.é   zDSpecifying a collation is unsupported with a max wire version of %d.)	Úmax_wire_versionr‰   Úok_for_legacyr   r„   r}   Úvalidate_sessionr™   rŠ   )r›   Ú	sock_infoÚexhaustÚuse_find_cmdr-   r-   r.   Úuse_command	  s*   
€ÿþÿÿÿz_Query.use_commandc                 C   sô   | j dur| j S d| jv }t| j| j| j| j| j| j| j| j	| j
| jƒ
}|r0d| _td|fgƒ}| j}|rT| |d| j¡ |sT|jjrT|jdurT|jsT|j| di ¡d< | ||| j¡ | j}|jrq|jjsq|j | j|d| j¡}|| jf| _ | j S )z.Return a find command document for this query.Nrv   ÚexplainFr|   ÚafterClusterTime)rš   r9   rŒ   r‡   r–   r•   ry   rˆ   r“   r‰   r}   rŠ   r˜   r   Ú	_apply_tor:   r€   Úcausal_consistencyÚoperation_timer…   Ú
setdefaultÚsend_cluster_timer™   Ú
_encrypterÚ_bypass_auto_encryptionÚencryptr”   r—   )r›   r©   r­   r‹   rŠ   r™   r-   r-   r.   Ú
as_command  sD   

ý
ÿþÿþÿÿz_Query.as_commandFc              
   C   sî   |r| j dB }n| j }|  ¡ }| j}|rA|  |¡d }|jr7td|| j| j|d| j|j	d�\}}}	}
|||	fS t
| jdf }d}n| jdkrHdpJ| j}| jrZ|rWt| j|ƒ}n| j}|jrct|| jƒ}t||| j|||rnd	n| j| j|j	d�S )
z6Get a query message, possibly setting the slaveOk bit.r¤   r   F©Úctxú$cmdr1   r   r   N)r“   r¢   r9   r·   Úop_msg_enabledÚ_op_msgr”   r:   r—   Úcompression_contextr    rˆ   ry   rl   Ú	is_mongosr;   Úqueryr•   r–   )r›   Úset_slave_okr©   Úuse_cmdr“   Únsr9   Ú
request_idÚmsgÚsizeÚ_Ú	ntoreturnr-   r-   r.   Úget_messageA  s:   ý
ÿþz_Query.get_message©F)r@   Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__Úexhaust_mgrr�   rœ   r¢   r¬   r·   rÈ   r-   r-   r-   r.   r’   æ   s    #r’   c                   @   sB   e Zd ZdZdZdZdd„ Zdd„ Zdd	„ Zd
d„ Z	ddd„Z
dS )Ú_GetMorezA getmore operation.)r”   r‡   rÇ   r�   r�   r—   r:   rŠ   r™   rÎ   rš   r�   c                 C   sF   || _ || _|| _|| _|| _|| _|| _|| _|	| _|
| _	d | _
d S 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œ   s  s   
z_GetMore.__init__c                 C   r�   rž   rŸ   r¡   r-   r-   r.   r¢   ‚  r£   z_GetMore.namespacec                 C   s    |  | j| j¡ |jdko| S )Nr¤   )r¨   r™   rŠ   r¦   )r›   r©   rª   r-   r-   r.   r¬   …  s   z_GetMore.use_commandc                 C   sŒ   | j dur| j S t| j| j| j| jƒ}| jr| j |d| j¡ | 	|| j| j
¡ | j
}|jr=|jjs=|j | j|d| j¡}|| jf| _ | j S )z1Return a getMore command document for this query.NF)rš   r‘   r�   r‡   rÇ   r�   rŠ   r¯   r:   r³   r™   r´   rµ   r¶   r”   r—   )r›   r©   r‹   r™   r-   r-   r.   r·   ‰  s$   

þÿÿz_GetMore.as_commandFc              
   C   s�   |   ¡ }|j}|r?|  |¡d }|jr+td|| jddd| j|jd�\}}}	}
|||	fS t| jdf }td|dd|d| j|d�S t	|| j
| j|ƒS )zGet a getmore message.r   NFr¸   rº   r1   )r¢   r½   r·   r»   r¼   r”   r—   r    r¿   Úget_morerÇ   r�   )r›   Údummy0r©   rÁ   rÂ   r¹   r9   rÃ   rÄ   rÅ   rÆ   r-   r-   r.   rÈ   Ÿ  s   
ý
z_GetMore.get_messageNrÉ   )r@   rÊ   rË   rÌ   rÍ   r˜   rœ   r¢   r¬   r·   rÈ   r-   r-   r-   r.   rÏ   j  s    rÏ   c                       s*   e Zd Z‡ fdd„Zd‡ fdd„	Z‡  ZS )Ú_RawBatchQueryc                    s   t t| ƒ ||¡ dS ©NF)ÚsuperrÒ   r¬   ©r›   Úsocket_inforª   ©r?   r-   r.   r¬   µ  s   z_RawBatchQuery.use_commandFc                    ó   t t| ƒ ||d¡S rÓ   )rÔ   rÒ   rÈ   ©r›   rÀ   r©   rÁ   r×   r-   r.   rÈ   »  ó   
ÿz_RawBatchQuery.get_messagerÉ   ©r@   rÊ   rË   r¬   rÈ   Ú__classcell__r-   r-   r×   r.   rÒ   ´  s    rÒ   c                       s&   e Zd Zdd„ Zd‡ fdd„	Z‡  ZS )Ú_RawBatchGetMorec                 C   s   dS rÓ   r-   rÕ   r-   r-   r.   r¬   Â  ó   z_RawBatchGetMore.use_commandFc                    rØ   rÓ   )rÔ   rÝ   rÈ   rÙ   r×   r-   r.   rÈ   Å  rÚ   z_RawBatchGetMore.get_messagerÉ   rÛ   r-   r-   r×   r.   rÝ   Á  s    rÝ   c                   @   s<   e Zd ZdZdd„ Zedd„ ƒZdd„ Zdd	„ Zd
d„ Z	dS )Ú_CursorAddresszEThe server address (host, port) of a cursor, with namespace property.c                 C   s   t  | |¡}||_|S rž   )ÚtupleÚ__new__Ú_CursorAddress__namespace)ÚclsÚaddressr¢   r›   r-   r-   r.   rá   Î  s   z_CursorAddress.__new__c                 C   ó   | j S )zThe namespace this cursor.)râ   r¡   r-   r-   r.   r¢   Ó  ó   z_CursorAddress.namespacec                 C   s   | | j f  ¡ S rž   )râ   Ú__hash__r¡   r-   r-   r.   rç   Ø  s   z_CursorAddress.__hash__c                 C   s*   t |tƒrt| ƒt|ƒko| j|jkS tS rž   )Ú
isinstancerß   rà   r¢   ÚNotImplemented©r›   Úotherr-   r-   r.   Ú__eq__Ý  s
   

ÿz_CursorAddress.__eq__c                 C   s
   | |k S rž   r-   rê   r-   r-   r.   Ú__ne__ã  s   
z_CursorAddress.__ne__N)
r@   rÊ   rË   rÌ   rá   Úpropertyr¢   rç   rì   rí   r-   r-   r-   r.   rß   Ë  s    
rß   z<iiiiiiBé   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Ü  )Úcompressr/   Ú_pack_compression_headerÚ_COMPRESSION_HEADER_SIZErU   Úcompressor_id)rV   Údatar¹   Ú
compressedrÃ   Úheaderr-   r-   r.   Ú	_compressê  s   

ùr÷   c                 C   s<   t dgƒ}| |¡ |  dd¡}td|d d dd|dtƒS )z$Data to send to do a lastError.
    )Úgetlasterrorr   Ú.r   r   ú.$cmdr1   N)r   r$   Úsplitr¿   r   )r¢   Úargsr‹   Úsplitnsr-   r-   r.   Ú__last_errorú  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.
    r`   r   )r/   Ú_pack_headerrU   )rV   rô   ÚridÚmessager-   r-   r.   Ú__pack_message  s   r  ú<ic                    sŠ   t ‰t|ƒdkrˆ|d ˆ ˆƒ}d dt| ƒ|g¡t|ƒfS ‡ ‡‡fdd„|D ƒ}|s/tdƒ‚d t|ƒt| ƒd |¡g¡ttt|ƒƒfS )zGet an OP_INSERT messager   r   r   r   c                    s   g | ]}ˆ|ˆ ˆƒ‘qS r-   r-   ©rr   Údoc©Ú
check_keysr   Úoptsr-   r.   ru     ó    z_insert.<locals>.<listcomp>úcannot do an empty bulk insert)r   rU   Újoinr   r   Ú	_pack_intrk   Úmap)Úcollection_nameÚdocsr  r“   r  Úencodedr-   r  r.   Ú_insert  s(   ýýýýr  c           
      C   s.   t | ||||ƒ\}}td||ƒ\}}	||	|fS )z9Internal compressed unacknowledged insert message helper.éÒ  )r  r÷   )
r  r  r  Úcontinue_on_errorr  r¹   Ú	op_insertÚmax_bson_sizer   rÄ   r-   r-   r.   Ú_insert_compressed'  s
   
ÿ
r  c                 C   sN   t | ||||ƒ\}}td|ƒ\}	}
|r"t| |ƒ\}	}}|	|
| |fS |	|
|fS )zInternal insert message helper.r  )r  r  rþ   )r  r  r  ÚsafeÚlast_error_argsr  r  r  r  r   rÄ   ÚglerÆ   r-   r-   r.   Ú_insert_uncompressed0  s   
ÿ
r  c                 C   s*   |rt | |||||ƒS t| ||||||ƒS )zGet an **insert** message.)r  r  )r  r  r  r  r  r  r  r¹   r-   r-   r.   r#   >  s   ÿ
ÿr#   c           
   	   C   sX   d}|r|d7 }|r|d7 }t }||||ƒ}	d tt| ƒt|ƒ||d|ƒ|	g¡t|	ƒfS )zGet an OP_UPDATE message.r   r   r   r   F©r   r  Ú_ZERO_32r   r  rU   )
r  ÚupsertÚmultir9   r  r  r  r“   r   Úencoded_updater-   r-   r.   Ú_updateH  s    
ûûr   c                 C   s2   t | ||||||ƒ\}}	td||ƒ\}
}|
||	fS )z9Internal compressed unacknowledged update message helper.éÑ  )r   r÷   )r  r  r  r9   r  r  r  r¹   Ú	op_updater  r   rÄ   r-   r-   r.   Ú_update_compressedY  s
   ÿ
r#  c	                 C   sR   t | ||||||ƒ\}	}
td|	ƒ\}}|r$t| |ƒ\}}}||| |
fS |||
fS )zInternal update message helper.r!  )r   r  rþ   )r  r  r  r9   r  r  r  r  r  r"  r  r   rÄ   r  rÆ   r-   r-   r.   Ú_update_uncompressedb  s   ÿ
r$  c
           
   
   C   s2   |	rt | |||||||	ƒS t| ||||||||ƒ	S )zGet an **update** message.)r#  r$  )
r  r  r  r9   r  r  r  r  r  r¹   r-   r-   r.   r$   p  s   ÿ

ÿr$   z<IBz<Bc                    s¶   t |dˆƒ}t| dƒ}t|ƒ}d}	|rOt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   r   c                    s   g | ]}t |ˆ ˆƒ‘qS r-   )r   r  ©r  r  r-   r.   ru   �  r	  z%_op_msg_no_header.<locals>.<listcomp>c                 s   ó   � | ]}t |ƒV  qd S rž   ©rU   r  r-   r-   r.   Ú	<genexpr>Ž  ó   € z$_op_msg_no_header.<locals>.<genexpr>r¤   c                 s   r&  rž   r'  r  r-   r-   r.   r(  ‘  r)  r   )	r   Ú_pack_op_msg_flags_typerU   Ú
_pack_byter   Úsumr  rk   r  )r“   rW   Ú
identifierr  r  r  r  Ú
flags_typeÚ
total_sizeÚmax_doc_sizeÚtype_oneÚcstringÚencoded_docsrÅ   Úencoded_sizerô   r-   r%  r.   Ú_op_msg_no_header~  s"   
ÿr5  c                 C   s4   t | |||||ƒ\}}}	td||ƒ\}
}|
|||	fS )zInternal OP_MSG message helper.éÝ  )r5  r÷   )r“   rW   r-  r  r  r  r¹   rÄ   r/  r  r   r-   r-   r.   Ú_op_msg_compressed™  s
   
ÿr7  c                 C   s2   t | |||||ƒ\}}}td|ƒ\}	}
|	|
||fS )z*Internal compressed OP_MSG message helper.r6  )r5  r  )r“   rW   r-  r  r  r  rô   r/  r  rÃ   Ú
op_messager-   r-   r.   Ú_op_msg_uncompressed¢  s
   
ÿr9  c              	   C   sÔ   ||d< |durd|vr|r|j stjj|d< n|j|d< tt|ƒƒ}zt |¡}	| |	¡}
W n t	y<   d}	d}
Y nw z%|rRt
| ||	|
|||ƒW |	rQ|
||	< S S t| ||	|
||ƒW |	rb|
||	< S S |	ri|
||	< w )zGet a OP_MSG message.ú$dbNr3   rF   )r4   r   ÚPRIMARY_PREFERREDr8   ÚnextÚiterÚ
_FIELD_MAPrT   r‚   ÚKeyErrorr7  r9  )r“   rW   Údbnamer:   Úslave_okr  r  r¹   r˜   r-  r  r-   r-   r.   r¼   ¬  s:   
ÿ

þÿ
ÿüÿ
ÿ
r¼   c                 C   s^   t |||ƒ}|rt |d|ƒ}	nd}	tt|ƒt|	ƒƒ}
d t| ƒt|ƒt|ƒt|ƒ||	g¡|
fS )zGet an OP_QUERY message.Fr   )r   rk   rU   r  r  r   )r€   r  Únum_to_skipÚnum_to_returnr¿   Úfield_selectorr  r  r  Úefsr  r-   r-   r.   Ú_queryÊ  s   úúrF  c	              	   C   s4   t | |||||||ƒ\}	}
td|	|ƒ\}}|||
fS )z)Internal compressed query message helper.éÔ  )rF  r÷   )r€   r  rB  rC  r¿   rD  r  r  r¹   Úop_queryr  r   rÄ   r-   r-   r.   Ú_query_compressedÜ  s   ø	
rI  c              	   C   s2   t | |||||||ƒ\}}	td|ƒ\}
}|
||	fS )zInternal query message helper.rG  )rF  r  )r€   r  rB  rC  r¿   rD  r  r  rH  r  r   rÄ   r-   r-   r.   Ú_query_uncompressedí  s   ø	
rJ  c	           	   
   C   s2   |rt | ||||||||ƒ	S t| |||||||ƒS )zGet a **query** message.)rI  rJ  )	r€   r  rB  rC  r¿   rD  r  r  r¹   r-   r-   r.   r¿   ÿ  s   þþr¿   z<qc                 C   s   d  tt| ƒt|ƒt|ƒg¡S )zGet an OP_GET_MORE message.r   )r  r  r   r  Ú_pack_long_long©r  rC  r�   r-   r-   r.   Ú	_get_more  s   ürM  c                 C   s   t dt| ||ƒ|ƒS )z+Internal compressed getMore message helper.éÕ  )r÷   rM  ©r  rC  r�   r¹   r-   r-   r.   Ú_get_more_compressed  s   ÿrP  c                 C   s   t dt| ||ƒƒS )z Internal getMore message helper.rN  )r  rM  rL  r-   r-   r.   Ú_get_more_uncompressed  s   ÿrQ  c                 C   s   |r	t | |||ƒS t| ||ƒS )zGet a **getMore** message.)rP  rQ  rO  r-   r-   r.   rÐ   %  s
   ÿrÐ   c                 C   s.   t |d|ƒ}d tt| ƒt|ƒ|g¡t|ƒfS )zGet an OP_DELETE message.Fr   r  )r  r9   r  r“   r  r-   r-   r.   Ú_delete-  s   üürR  c           	      C   s,   t | |||ƒ\}}td||ƒ\}}|||fS )z9Internal compressed unacknowledged delete message helper.éÖ  )rR  r÷   )	r  r9   r  r“   r¹   Ú	op_deleter  r   rÄ   r-   r-   r.   Ú_delete_compressed7  s   
rU  c                 C   sL   t | |||ƒ\}}td|ƒ\}}	|r!t| |ƒ\}}
}||	|
 |fS ||	|fS )zInternal delete message helper.rS  )rR  r  rþ   )r  r9   r  r  r  r“   rT  r  r   rÄ   r  rÆ   r-   r-   r.   Ú_delete_uncompressed>  s   
rV  c                 C   s&   |r
t | ||||ƒS t| |||||ƒS )zàGet a **delete** message.

    `opts` is a CodecOptions. `flags` is a bit vector that may contain
    the SingleRemove flag or not:

    http://docs.mongodb.org/meta-driver/latest/legacy/mongodb-wire-protocol/#op-delete
    )rU  rV  )r  r9   r  r  r  r“   r¹   r-   r-   r.   r%   I  s
   	ÿr%   c                 C   s8   t | ƒ}t dd|  ¡j}|d|g| ¢R Ž }td|ƒS )z#Get a **killCursors** message.
    z<iirS   r   i×  )rU   ÚstructÚStructÚpackr  )Ú
cursor_idsÚnum_cursorsrY  Úop_kill_cursorsr-   r-   r.   Úkill_cursorsX  s   
r]  c                   @   s    e Zd ZdZdZdd„ Zdd„ Zd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dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!S )"Ú_BulkWriteContextzCA wrapper around SocketInfo for use with write splitting functions.)Údb_namerW   r©   Úop_idr˜   ÚfieldÚpublishÚ
start_timeÚ	listenersrŠ   rð   Úop_typeÚcodecc	           	      C   s|   || _ || _|| _|| _|| _|j| _tt|ƒƒ| _	t
| j	 | _| jr(tj ¡ nd | _|| _|jr3dnd| _|| _|| _d S )NTF)r_  rW   r©   r`  rd  Úenabled_for_commandsrb  r<  r=  r˜   r>  ra  ÚdatetimeÚnowrc  rŠ   r½   rð   re  rf  )	r›   Údatabase_namerW   r©   Úoperation_idrd  rŠ   re  rf  r-   r-   r.   rœ   h  s   
z_BulkWriteContext.__init__c                 C   sB   | j d }t|| j| j|| j| j| ƒ\}}}|stdƒ‚|||fS )Nrú   úcannot do an empty bulk write)r_  Ú_do_bulk_write_commandre  rW   r  rf  r   )r›   r  r¢   rÃ   rÄ   Úto_sendr-   r-   r.   Ú_batch_commandx  s   

þ
z _BulkWriteContext._batch_commandc                 C   s4   |   |¡\}}}|  |||¡}| || j¡ ||fS rž   )ro  Úwrite_commandÚ_process_responserŠ   )r›   r  r™   rÃ   rÄ   rn  rX   r-   r-   r.   Úexecute�  s   z_BulkWriteContext.executec                 C   s&   |   |¡\}}}|  ||dd|¡ |S )Nr   F)ro  Úlegacy_write)r›   r  r™   rÃ   rÄ   rn  r-   r-   r.   Úexecute_unack‡  s   z_BulkWriteContext.execute_unackc                 C   s
   | j tkS )z-Should we check keys for this operation type?)re  Ú_INSERTr¡   r-   r-   r.   r  ‘  s   
z_BulkWriteContext.check_keysc                 C   ó   | j jS )z#A proxy for SockInfo.max_bson_size.)r©   r  r¡   r-   r-   r.   r  –  ó   z_BulkWriteContext.max_bson_sizec                 C   s   | j r	| jjd S | jjS )z&A proxy for SockInfo.max_message_size.r`   )rð   r©   Úmax_message_sizer¡   r-   r-   r.   rx  ›  s   z"_BulkWriteContext.max_message_sizec                 C   rv  )z*A proxy for SockInfo.max_write_batch_size.)r©   Úmax_write_batch_sizer¡   r-   r-   r.   ry  £  rw  z&_BulkWriteContext.max_write_batch_sizec                 C   rå   )z:The maximum size of a BSON command before batch splitting.)r  r¡   r-   r-   r.   Úmax_split_size¨  ræ   z _BulkWriteContext.max_split_sizec                 C   s*   |rt d|| jjƒ\}}|  |||||¡S )Nr  )r÷   r©   r½   rs  )r›   rÃ   rÄ   r0  Úacknowledgedr  rð   r-   r-   r.   Úlegacy_bulk_insert­  s   
ÿ
ÿz$_BulkWriteContext.legacy_bulk_insertc              
   C   sø   | j rtj ¡ | j }|  ||¡}tj ¡ }z^z.| j ||||¡}	| j rDtj ¡ | | }|	dur9t| j||	ƒ}
nddi}
|  	||
|¡ W n& t
yk } z| j rftj ¡ | | }|  |t| j||jƒ|¡ ‚ d}~ww W tj ¡ | _|	S tj ¡ | _w )zKA proxy for SocketInfo.legacy_write that handles event publishing.
        NrD   r   )rb  rh  ri  rc  Ú_startr©   rs  r\   r˜   Ú_succeedr   Ú_failÚdetails)r›   rÃ   rÄ   r0  r{  r  Údurationr‹   ÚstartrX   ÚreplyÚexcr-   r-   r.   rs  µ  s@   
ÿ€
ÿü€ø€
ÿz_BulkWriteContext.legacy_writec              
   C   sÊ   | j rtj ¡ | j }|  ||¡ tj ¡ }zGz| j ||¡}| j r2tj ¡ | | }|  |||¡ W n! tyT } z| j rOtj ¡ | | }|  	||j
|¡ ‚ d}~ww W tj ¡ | _|S tj ¡ | _w )zLA proxy for SocketInfo.write_command that handles event publishing.
        N)rb  rh  ri  rc  r}  r©   rp  r~  r   r  r€  )r›   rÃ   rÄ   r  r�  r‚  rƒ  r„  r-   r-   r.   rp  Ô  s*   
€€ü€ÿz_BulkWriteContext.write_commandc                 C   s4   | j  ¡ }||| j< | j || j|| jj| j¡ |S )zPublish a CommandStartedEvent.)	rW   Úcopyra  rd  Úpublish_command_startr_  r©   rä   r`  )r›   rÃ   r  r‹   r-   r-   r.   r}  é  s   

þz_BulkWriteContext._startc                 C   ó"   | j  ||| j|| jj| j¡ dS )z Publish a CommandSucceededEvent.N)rd  Úpublish_command_successr˜   r©   rä   r`  )r›   rÃ   rƒ  r�  r-   r-   r.   r~  ò  ó   þz_BulkWriteContext._succeedc                 C   r‡  )zPublish a CommandFailedEvent.N)rd  Úpublish_command_failurer˜   r©   rä   r`  )r›   rÃ   Úfailurer�  r-   r-   r.   r  ø  r‰  z_BulkWriteContext._failN)r@   rÊ   rË   rÌ   rÍ   rœ   ro  rr  rt  rî   r  r  rx  ry  rz  r|  rs  rp  r}  r~  r  r-   r-   r-   r.   r^  a  s.    	





	r^  i    c                   @   s4   e Zd ZdZdd„ Zdd„ Zdd„ Zedd	„ ƒZd
S )Ú_EncryptedBulkWriteContextr-   c                 C   sd   | j d }t|| j| j|| j| j| ƒ\}}|stdƒ‚| dd¡d }tt	|ƒ|d … t
ƒ}||fS )Nrú   rl  r   r¤   é	   )r_  Ú_encode_batched_write_commandre  rW   r  rf  r   rM   r   Ú
memoryviewr	   )r›   r  r¢   rÄ   rn  Ú	cmd_startr‹   r-   r-   r.   ro  	  s   
þÿz)_EncryptedBulkWriteContext._batch_commandc                 C   s0   |   |¡\}}| jj| j|t| j|d�}||fS )N)r—   rŠ   r™   )ro  r©   rW   r_  Ú_UNICODE_REPLACE_CODEC_OPTIONSrŠ   )r›   r  r™   r‹   rn  rX   r-   r-   r.   rr    s   þz"_EncryptedBulkWriteContext.executec                 C   s2   |   |¡\}}| jj| j|tdd�| j|d� |S )Nr   )Úw)Úwrite_concernrŠ   r™   )ro  r©   rW   r_  r   rŠ   )r›   r  r™   r‹   rn  r-   r-   r.   rt    s   þz(_EncryptedBulkWriteContext.execute_unackc                 C   s   t S )z Reduce the batch splitting size.)Ú_MAX_SPLIT_SIZE_ENCr¡   r-   r-   r.   rz  %  ó   z)_EncryptedBulkWriteContext.max_split_sizeN)	r@   rÊ   rË   rÍ   ro  rr  rt  rî   rz  r-   r-   r-   r.   rŒ    s    rŒ  c                 C   s&   | dkrt d||f ƒ‚t d| f ƒ‚)z-Internal helper for raising DocumentTooLarge.r#   zfBSON document too large (%d bytes) - the connected server supports BSON document sizes up to %d bytes.z%r command document too large)r   )rV   Údoc_sizeÚmax_sizer-   r-   r.   Ú_raise_document_too_large+  s
   ýr˜  c                    sà  ‡ ‡fdd„}|p| }	d}
t ƒ }| t dt|ƒ¡¡ | tˆ ƒ¡ | ¡  }}d}g }t}|jo6|p5|	 }|D ]‹}||||ƒ}t	|ƒ}||j
k}||7 }||jk rb|sb| |¡ | |¡ d}q9|r¦z|rod| ¡ }}n	|| ¡ |	ƒ\}}| ||d|	||¡ W n" ty¥ } z|r�|}
n|sšW Y d}~ dS ‚ W Y d}~nd}~ww |r¯td||j
ƒ || }| |¡ | ¡  | |¡ |g}q9|sËtd	ƒ‚|rÕd| ¡ }}n	|| ¡ |ƒ\}}| ||d|||¡ |
durî|
‚dS )
z*Insert `docs` using multiple batches.
    c                    s2   t d| ƒ\}}|rtˆ ˆƒ\}}}||7 }||fS )z6Build the insert message with header and GLE.
        r  )r  rþ   )Úinsert_messageÚ	send_saferÃ   Úfinal_messageÚerror_messagerÆ   ©r  r  r-   r.   Ú_insert_message=  s   
ÿz+_do_batched_insert.<locals>._insert_messageNr  FTr   r#   r
  )r   ÚwriterW  rY  Úintr   Útellr   rð   rU   r  rx  ÚappendÚgetvaluer|  r   r˜  ÚseekÚtruncater   )r  r  r  r  r  r  r  r¹   rž  rš  Ú
last_errorrô   Úmessage_lengthÚ	begin_locÚhas_docsrn  r   rð   r  r  Úencoded_lengthÚ	too_larger   rÄ   r„  rÃ   r-   r�  r.   Ú_do_batched_insert8  sp   




ÿú€üÿ

ÿr¬  s
   documents s   updates s   deletes c                 C   sr  |j }|j}	|j}
|rdnd}| |¡ | d¡ | t|d|ƒ¡ | d¡ | ¡ }| d¡ z	| t|  ¡ W n tyD   tdƒ‚w | t	t
fv rMd}g }d}|D ]O}t|||ƒ}t|ƒ}| ¡ | }|dkol||
k}| os||k}|sx|rˆtt ¡ ƒ|  }t|t|ƒ|ƒ ||
krŽ n| |¡ | |¡ |d7 }||	kr¢ nqS| ¡ }| |¡ | t|| ƒ¡ ||fS )	zCreate a batched OP_MSG write.r   s      r   Fó   úUnknown commandr   r   )r  ry  rx  rŸ  r   r¡  Ú_OP_MSG_MAPr?  r   Ú_UPDATEÚ_DELETErU   Úlistr>  Úkeysr˜  r¢  r¤  r  )rV   rW   r  r  Úackr  r¹   Úbufr  ry  rx  r“   Úsize_locationrn  Úidxr  ÚvalueÚ
doc_lengthÚnew_message_sizeÚdoc_too_largeÚunacked_doc_too_largeÚwrite_opÚlengthr-   r-   r.   Ú_batched_op_msg_impl—  sT   



ÿ
ÿ

ÿ
r¿  c           
   	   C   ó,   t ƒ }t| |||||||ƒ\}}	| ¡ |fS )zOEncode the next batched insert, update, or delete operation
    as OP_MSG.
    )r   r¿  r£  )
rV   rW   r  r  r´  r  r¹   rµ  rn  rÆ   r-   r-   r.   Ú_encode_batched_op_msgØ  s
   ÿrÁ  c                 C   ó6   t | ||||||ƒ\}}td||jjƒ\}	}
|	|
|fS )z]Create the next batched insert, update, or delete operation
    with OP_MSG, compressed.
    r6  )rÁ  r÷   r©   r½   )rV   rW   r  r  r´  r  r¹   rô   rn  rÃ   rÄ   r-   r-   r.   Ú_batched_op_msg_compressedæ  s   ÿý
rÃ  c              	   C   óx   t ƒ }| t¡ | d¡ t| |||||||ƒ\}}	| d¡ tƒ }
| t|
ƒ¡ | d¡ | t|	ƒ¡ |
| ¡ |fS )z"OP_MSG implementation entry point.s       Ý  r¤   r   )r   rŸ  Ú_ZERO_64r¿  r¤  r/   r  r£  )rV   rW   r  r  r´  r  r¹   rµ  rn  r¾  rÃ   r-   r-   r.   Ú_batched_op_msgõ  s   

ÿ

rÆ  c                 C   sf   |   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   r:  ÚwriteConcernr’  T)rû   ÚboolrT   r©   r½   rÃ  rÆ  )r¢   rV   rW   r  r  r  r¹   r´  r-   r-   r.   Ú_do_batched_op_msg  s   ÿÿrÉ  c                 C   rÂ  )zKCreate the next batched insert, update, or delete command, compressed.
    rG  )rŽ  r÷   r©   r½   )r¢   rV   rW   r  r  r  r¹   rô   rn  rÃ   rÄ   r-   r-   r.   Ú!_batched_write_command_compressed"  s   ÿý
rÊ  c           
   	   C   rÀ  )z?Encode the next batched insert, update, or delete command.
    )r   Ú_batched_write_command_implr£  )
r¢   rV   rW   r  r  r  r¹   rµ  rn  rÆ   r-   r-   r.   rŽ  0  s
   ÿrŽ  c              	   C   rÄ  )z?Create the next batched insert, update, or delete command.
    s       Ô  r¤   r   )r   rŸ  rÅ  rË  r¤  r/   r  r£  )r¢   rV   rW   r  r  r  r¹   rµ  rn  r¾  rÃ   r-   r-   r.   Ú_batched_write_command=  s   

ÿ

rÌ  c                 C   s0   |j jrt| ||||||ƒS t| ||||||ƒS )z#Batched write commands entry point.)r©   r½   rÊ  rÌ  ©r¢   rV   rW   r  r  r  r¹   r-   r-   r.   Ú_do_batched_write_commandX  s   ÿÿrÎ  c                 C   s4   |j jdkrt| ||||||ƒS t| ||||||ƒS )z Bulk write commands entry point.r¥   )r©   r¦   rÉ  rÎ  rÍ  r-   r-   r.   rm  b  s   ÿÿrm  c                 C   sØ  |j }|j}	|t }
|j}| t¡ | t| ƒ¡ | t¡ | t¡ | 	¡ }| t
|ƒ¡ | dd¡ | ¡  z	| t| ¡ W n tyL   tdƒ‚w |ttfv rUd}| 	¡ d }g }d}|D ]_}tt|ƒƒ}t
|||ƒ}t|ƒ|
k}|r‡tt ¡ ƒ| }t|t|ƒ|ƒ |dko˜| 	¡ t|ƒ t|ƒ |k}||	k}|s¡|r£ n| t¡ | |¡ | t¡ | |¡ | |¡ |d7 }qa| t¡ | 	¡ }| |¡ | t|| d ƒ¡ | |¡ | t|| ƒ¡ ||fS )z(Create a batched OP_QUERY write command.r1   r   r®  Fr¤   r   r   )r  ry  Ú_COMMAND_OVERHEADrz  rŸ  r  r
   Ú_ZERO_8Ú_SKIPLIMr¡  r   r¤  r¥  Ú_OP_MAPr?  r   r°  r±  r>   rU   r²  r>  r³  r˜  Ú_BSONOBJr¢  Ú_ZERO_16r  )r¢   rV   rW   r  r  r  r¹   rµ  r  ry  Úmax_cmd_sizerz  Úcommand_startÚ
list_startrn  r·  r  rs   r¸  r»  r½  Úenough_dataÚenough_documentsr¾  r-   r-   r.   rË  l  sd   


ÿ
ÿÿ








rË  c                   @   ód   e Zd ZdZdZe d¡jZdZ	dd„ Z
ddd	„Zdedd
fdd„Zdd„ Zdd„ Zedd„ ƒZdS )Ú_OpReplyz$A MongoDB OP_REPLY response message.©r“   r�   Únumber_returnedr    z<iqiir   c                 C   s   || _ || _|| _|| _d S rž   rÜ  )r›   r“   r�   rÝ  r    r-   r-   r.   rœ   ¿  s   
z_OpReply.__init__Nc                 C   sÈ   | j d@ r|du rtdƒ‚d|f }d|ddœ}t|d|ƒ‚| j d@ r`t | j¡ ¡ }| d	d¡ |d
  d¡r?t	|d
 |ƒ‚| 
d¡dkrRt| 
d
¡| 
d¡|ƒ‚td| 
d
¡ | 
d¡|ƒ‚| jgS )aº  Check the response header from the database, without decoding BSON.

        Check the response for errors and unpack.

        Can raise CursorNotFound, NotMasterError, ExecutionTimeout, or
        OperationFailure.

        :Parameters:
          - `cursor_id` (optional): 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   é+   )rD   r<   rI   r   rD   z$errz
not masterrI   é2   zdatabase error: %s)r“   r   r   ÚbsonÚBSONr    r   r²   Ú
startswithr   rT   r   r   )r›   r�   rÄ   ÚerrobjÚerror_objectr-   r-   r.   Úraw_responseÅ  s.   



þÿýz_OpReply.raw_responseFc                 C   s,   |   |¡ |rt | j|¡S t | j||¡S )ad  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, NotMasterError, ExecutionTimeout, or
        OperationFailure.

        :Parameters:
          - `cursor_id` (optional): cursor_id we sent to get this response -
            used for raising an informative exception when we get cursor id not
            valid at server response
          - `codec_options` (optional): an instance of
            :class:`~bson.codec_options.CodecOptions`
        )rå  rà  Ú
decode_allr    Ú_decode_all_selective©r›   r�   r—   Úuser_fieldsÚlegacy_responser-   r-   r.   Úunpack_responseì  s   
ÿz_OpReply.unpack_responsec                 C   s   |   ¡ }| jdksJ ‚|d S )úUnpack a command response.r   r   )rë  rÝ  )r›   r  r-   r-   r.   Úcommand_response  s   z_OpReply.command_responsec                 C   ó   t ‚©z)Return the bytes of the command response.©ÚNotImplementedErrorr¡   r-   r-   r.   Úraw_command_response
  r•  z_OpReply.raw_command_responsec                 C   s0   |   |¡\}}}}t|dd… ƒ}| ||||ƒS )z%Construct an _OpReply from raw bytes.é   N)ÚUNPACK_FROMÚbytes)rã   rÄ   r“   r�   rÆ   rÝ  r    r-   r-   r.   Úunpack  s   z_OpReply.unpackrž   ©r@   rÊ   rË   rÌ   rÍ   rW  rX  Úunpack_fromrô  ÚOP_CODErœ   rå  r‘  rë  rí  rò  Úclassmethodrö  r-   r-   r-   r.   rÛ  ·  s    
'
þrÛ  c                   @   rÚ  )Ú_OpMsgz"A MongoDB OP_MSG response message.)r“   r�   rÝ  Úpayload_documentz<IBir6  c                 C   s   || _ || _d S rž   )r“   rü  )r›   r“   rü  r-   r-   r.   rœ   #  s   
z_OpMsg.__init__Nc                 C   rî  rž   rð  )r›   r�   r-   r-   r.   rå  '  rÞ   z_OpMsg.raw_responseFc                 C   s   |rJ ‚t  | j||¡S )zûUnpack a OP_MSG command response.

        :Parameters:
          - `cursor_id` (optional): Ignored, for compatibility with _OpReply.
          - `codec_options` (optional): an instance of
            :class:`~bson.codec_options.CodecOptions`
        )rà  rç  rü  rè  r-   r-   r.   rë  *  s   ÿz_OpMsg.unpack_responsec                 C   s   |   ¡ d S )rì  r   )rë  r¡   r-   r-   r.   rí  9  r0   z_OpMsg.command_responsec                 C   rå   rï  )rü  r¡   r-   r-   r.   rò  =  s   z_OpMsg.raw_command_responsec                 C   sn   |   |¡\}}}|dkrtd|f ƒ‚|dkrtd|f ƒ‚t|ƒ|d kr*tdƒ‚t|dd… ƒ}| ||ƒS )z#Construct an _OpMsg from raw bytes.r   zUnsupported OP_MSG flags (%r)z$Unsupported OP_MSG payload type (%r)r¥   z$Unsupported OP_MSG reply: >1 sectionN)rô  r   rU   rõ  )rã   rÄ   r“   Úfirst_payload_typeÚfirst_payload_sizerü  r-   r-   r.   rö  A  s   ÿ
z_OpMsg.unpackrž   r÷  r-   r-   r-   r.   rû    s    

þrû  c
                 C   sx  t d||d|d|||dtdddƒ}tt|ƒƒ}
|	j}|r!tj ¡ }| || ¡\}}}|rAtj ¡ | }|	 |||| j	¡ tj ¡ }|  
||¡ |  |¡}z| d|¡}W n1 ty… } z%|r€tj ¡ | | }t|ttfƒrr|j}nt|ƒ}|	 |||
|| j	¡ ‚ d}~ww d|v r™||jd||f dœddœ}n|rŸ|d ni }d|d< |rºtj ¡ | | }|	 |||
|| j	¡ |S )	zESimple query helper for retrieving a first (and possibly only) batch.r   NÚcursorr&   )Ú
firstBatchÚidrÂ   g      ð?)rÿ  rD   rD   )r’   r   r<  r=  rg  rh  ri  rÈ   r†  rä   Úsend_messageÚreceive_messagerë  Ú	Exceptionrè   r   r   r€  rB   rŠ  r�   rˆ  )r©   r”   r‡   r¿   rÇ   rA  r—   r:   r‹   rd  r˜   rb  r‚  rÃ   rÄ   r0  Úencoding_durationrƒ  r  r„  r�  r‹  rX   r-   r-   r.   Ú_first_batchZ  s^   ý

ÿ

ÿ€÷
ýú
ÿr  )NNrž   )FNrÉ   )r   )r   N)‡rÌ   rh  r)   rW  rà  r   r   r   r   r   Úbson.codec_optionsr   Úbson.raw_bsonr   r	   Úbson.py3compatr
   r   Úbson.sonr   Úpymongor   Ú_use_cÚImportErrorÚpymongo.errorsr   r   r   r   r   r   r   r   Úpymongo.read_concernr   Úpymongo.read_preferencesr   Úpymongo.write_concernr   r,   r+   rÏ  ru  r°  r±  Ú_EMPTYrÓ  rÐ  rÔ  r  rÅ  rÑ  rÒ  r>  r    r‘  r/   r;   rB   r\   r†   rq   rŒ   r‘   Úobjectr’   rÏ   rÒ   rÝ   rà   rß   rX  rY  rñ   rò   r÷   rþ   rÿ   r  r  r  r  r  rž  r#   r   r#  r$  Ú_update_messager$   r*  r+  r5  r7  r9  r¼   rF  rI  rJ  Ú_query_messager¿   rK  rM  rP  rQ  Ú_get_more_messagerÐ   rR  rU  rV  r%   r]  r^  r”  rŒ  r˜  r¬  r¯  r¿  rÁ  rÃ  rÆ  rÉ  rÊ  rŽ  rÌ  rÎ  rm  rË  rÛ  rû  rù  rö  Ú_UNPACK_REPLYr  r-   r-   r-   r.   Ú<module>   s,  ÿ(ýýÿ'
ÿ# J


	

ÿ
	

ÿ
	
ÿ
þ
ÿ
ÿ	


ÿ
ÿ	 #%RýA
	

Kd:þ