
    phm/                    2   % S r SSKJr  SSKrSSKrSSKJr  SSKJrJ	r	J
r
JrJrJrJrJrJr  SSKJr  SSKJrJrJrJrJrJrJrJrJr  SSKJr  \(       a  SS	KJ r   SS
K!J"r"  SSK#J$r$  SSK%J&r&  \'" SS/5      r(S\)S'   \'" / SQ5      \(-  r*S\)S'   \*\'" / SQ5      -  r+S\)S'   Sr,S\)S'   Sr-S\)S'   1 Skr.S\)S'   S*S jr/S+S jr0S,S jr1 S-     S.S  jjr2S/S! jr3S0S" jr4   S1           S2S# jjr5S3S$ jr6S4S% jr7S5S& jr8S6S' jr9      S7S( jr:S8S) jr;g)9zCBits and pieces used by the driver that don't really fit elsewhere.    )annotationsN)abc)	TYPE_CHECKINGAny	ContainerIterableMappingNoReturnOptionalSequenceUnion)	ASCENDING)	CursorNotFoundDuplicateKeyErrorExecutionTimeoutNotPrimaryErrorOperationFailureWriteConcernError
WriteErrorWTimeoutError_wtimeout_error)HelloCompat)_Hint)
_IndexList)PoolOptions)_DocumentOutiP-  [   zfrozenset[int]_SHUTDOWN_CODES)iJ'  i{'  i{4  iR-  i|4     _NOT_PRIMARY_CODES)      Y   i)#  i     _RETRYABLE_ERROR_CODESi  int_REAUTHENTICATION_REQUIRED_CODE   _AUTHENTICATION_FAILURE_CODE>	   copydbgetnonce	saslstart
createuser
updateuserauthenticatesaslcontinuecopydbgetnoncecopydbsaslstartzset[str]_SENSITIVE_COMMANDSc                    SSK Jn  0 nUR                  5       nU R                  nU R                  nU(       a  US-  US'   U(       a  U(       d  US-  US'   U(       a  US-  US'   U$ )Nr   )_csoti  	timeoutMSsocketTimeoutMSconnectTimeoutMS)pymongor5   get_timeoutsocket_timeoutconnect_timeout)optionsr5   detailstimeoutr;   r<   s         P/home/james-whalen/.local/lib/python3.13/site-packages/pymongo/helpers_shared.py_get_timeout_detailsrA   p   sl    G!G++N--O&~g%3d%:!"&5&<"#N    c                r    SnU (       a-  US-  nS H  nX ;   d  M
  USU SX    S3-  nM     US S nUS-  nU$ )	N z (configured timeouts:)r7   r6   r8    z: zms,) )r>   resultr?   s      r@   format_timeout_detailsrJ      s^    F**KG!AgYb)9(:#>> L #MrB   c                j    SR                  U  Vs/ s H  nSR                  " U6 PM     sn5      $ s  snf )z9Generate an index name from the set of fields it is over._z{}_{})joinformat)keysitems     r@   _gen_index_namerQ      s,    88t<ttW^^T*t<==<s   0c                B   Ub0  [        U [        5      (       d  [        S[        U 5       35      eX4/$ [        U [        5      (       a	  U [        4/$ [        U [
        R                  5      (       a  [        U 5      $ [        U [
        R                  5      (       a  [        U R                  5       5      $ [        U [        [        45      (       d  [        S[        U 5       35      e/ nU  H1  n[        U[        5      (       a  U[        4nUR                  U5        M3     U$ )zyHelper to generate a list of (key, direction) pairs.

Takes such a list, or a single key, or a single key and direction.
z'Expected a string and a direction, not zKif no direction is specified, key_or_list must be an instance of list, not )
isinstancestr	TypeErrortyper   r   	ItemsViewlistr	   itemstupleappend)key_or_list	directionvaluesrP   s       r@   _index_listr_      s    +s++Ed;FWEXYZZ())k3'' ),--S]]33$$S[[11))+,,K$77]^bcn^o]pq  )+D$$$i(MM$   rB   c                   [        U [        [        [        R                  45      (       d  [        S[        U 5      -   5      e[        U 5      (       d  [        S5      e0 n[        U [        R                  5      (       a  U  H  nX   n[        X#5        X1U'   M     U$ U  H3  n[        U[        5      (       a  U[        4nUu  p#[        X#5        X1U'   M5     U$ )zZHelper to generate an index specifying document.

Takes a list of (key, direction) pairs.
z@must use a dictionary or a list of (key, direction) pairs, not: zkey_or_list must not be empty)rS   rX   rZ   r   r	   rU   reprlen
ValueError_validate_index_key_pairrT   r   )
index_listindexkeyvaluerP   s        r@   _index_documentri      s    
 j4"<==NQUV`Qaa
 	
 z??899E*ckk**COE$S0#J  L D$$$i(JC$S0#J  LrB   c                    [        U [        5      (       d  [        S[        U 5       35      e[        U[        [        [
        R                  45      (       d  [        S[        U5       35      eg )Nz<first item in each key pair must be an instance of str, not zasecond item in each key pair must be 1, -1, '2d', or another valid MongoDB index specifier., not )rS   rT   rU   rV   r&   r   r	   )rg   rh   s     r@   rd   rd      sg    c3VW[\_W`Vabccec3455%[M#
 	
 6rB   c                N   SU ;  a,  [        U R                  S5      U R                  S5      U U5      eU(       aA  SU ;   a;  U S   nU R                  S5      nU(       a  UR                  SU05        [        U5        U S   (       a  gU nSU ;   aL  U S   R	                  5        H5  nUR                  S5      (       d  M  UR                  S5      (       a  M3  Un  O   US   n	UR                  S5      n
U(       a  U
b  X;   a  gOX;   a  gU
b  U
[
        ;   a  [        X5      eO%[        R                  U	;   d  S	U	;   a  [        X5      eU
S
;   a  [        XX5      eU
S:X  a,  U(       a  [        U5      nU	[        U5      -  n	[        XX5      eU
S:X  a  [        XX5      e[        XX5      e)z+Check the response to a command for errors.okz$errcodewriteConcernErrorerrorLabelsNrawerrmsgznode is recovering)*  i*  i&1  2   +   )r   getupdate_raise_write_concern_errorr^   r    r   r   LEGACY_ERRORr   rA   rJ   r   r   )responsemax_wire_versionallowable_errorsparse_write_concern_error	pool_opts_error_labelsr>   shardrq   rm   timeout_detailss               r@   _check_command_responser      s    8LL LL 	
 	
 !%8H%D-.,,}-MM='23"6*~G e_++-Eyy""599T??	 . XF;;vD ' (' %%!&33 &		!	!V	+/Cv/Mf// $$hII	29=O,_==FvXHH	V8FF
6
DDrB   c                    U S   nUR                  S5      S:X  a  [        UR                  S5      SU5      e[        UR                  S5      UR                  S5      U5      e)NrF   rm   rr   rq   )ru   r   r   )write_errorserrors     r@   _raise_last_write_errorr     sX     EyyE!		( 3UEBB
UYYx(%))F*;U
CCrB   c                    [        U 5      (       a+  [        U R                  S5      U R                  S5      U 5      e[        U R                  S5      U R                  S5      U 5      e)Nrq   rm   )r   r   ru   r   )r   s    r@   rw   rw   (  sO    uEIIh/61BEJJ
EIIh/61BE
JJrB   c                    U R                  S5      nU(       a,  U R                  S5      nU(       a  UR                  5       nX!S'   U$ )z%Return the writeConcernError or None.rn   ro   )ru   copy)rI   wceerror_labelss      r@   _get_wce_docr   /  s?    
**(
)C
 zz-0((*C!-JrB   c                    U R                  S5      nU(       a  [        U5        [        U 5      nU(       a  [        U5        gg)z?Backward compatibility helper for write command error handling.writeErrorsN)ru   r   r   rw   )rI   r   r   s      r@   _check_write_command_responser   =  s7     ::m,L-
v
C
"3' rB   c                4   [        U [        R                  5      (       a  U $ [        U [        R                  [        R                  45      (       a;  [        S U  5       5      (       d  [        U S35      e[        R                  U S5      $ [        U S35      e)zTakes a sequence of field names and returns a matching dictionary.

["a", "b"] becomes {"a": 1, "b": 1}

and

["a.b.c", "d", "a.c"] becomes {"a.b.c": 1, "d": 1, "a.c": 1}
c              3  B   #    U  H  n[        U[        5      v   M     g 7fN)rS   rT   ).0fields     r@   	<genexpr>'_fields_list_to_dict.<locals>.<genexpr>X  s     >ve:eS))vs   z5 must be a list of key names, each an instance of str   z' must be a mapping or list of key names)	rS   r   r	   r   SetallrU   dictfromkeys)fieldsoption_names     r@   _fields_list_to_dictr   I  s|     &#++&&&3<<122>v>>>{m+`abb}}VQ''
{m#JK
LLrB   c                     [         R                  (       aI  [         R                  " 5       n  [        R                  " U S   U S   U S   S[         R                  5        A gg! [
         a     Nf = f! A f = f)z1Print exceptions raised by subscribers to stderr.r   r      N)sysstderrexc_info	tracebackprint_exceptionOSError)einfos    r@   _handle_exceptionr   _  se     zz	%%eAha%(D#**U    		 s#   1A   
A-*A0 ,A--A0 0A3)r=   r   returnzdict[str, float])r>   zOptional[dict[str, float]]r   rT   )rO   r   r   rT   r   )r\   r   r]   zOptional[Union[int, str]]r   z8Sequence[tuple[str, Union[int, str, Mapping[str, Any]]]])re   r   r   zdict[str, Any])rg   r   rh   r   r   None)NFN)ry   r   rz   zOptional[int]r{   z$Optional[Container[Union[int, str]]]r|   boolr}   zOptional[PoolOptions]r   r   )r   z	list[Any]r   r
   )r   r   r   r
   )rI   Mapping[str, Any]r   zOptional[Mapping[str, Any]])rI   r   r   r   )r   z'Union[Mapping[str, Any], Iterable[str]]r   rT   r   r   )r   r   )<__doc__
__future__r   r   r   collectionsr   typingr   r   r   r   r	   r
   r   r   r   r9   r   pymongo.errorsr   r   r   r   r   r   r   r   r   pymongo.hellor   pymongo.cursor_sharedr   pymongo.operationsr   pymongo.pool_optionsr   pymongo.typingsr   	frozensetr   __annotations__r    r%   r'   r)   r3   rA   rJ   rQ   r_   ri   rd   r   r   rw   r   r   r   r   rH   rB   r@   <module>r      s   J " 
  
 
 
 
 
 
 &+-0,
 #,
#  	
	 
 N  *<i	? 	*  	 (+  * %' c &

! X 
 	> @D#<=<:
 >B&+'+EEEE#EE ;EE  $	EE
 %EE 
EEPDK	(M3MBEMM,rB   