
    i
                       % S r SSKJr  SSKrSSKrSSKJrJr  SSKJ	r	  SSK
JrJr  SSKJrJrJr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  SS
KJr  SSK J!r!J"r"J#r#  SSK$J%r%  SSK&J'r'J(r(  SSK)J*r*  SSK+J,r,  SSK-J.r.  SSK/J0r0  SSK1J2r2J3r3  SSK4J5r5  SSK6J7r7J8r8J9r9  \(       a  SSK:J;r;  \\4r<S\=S'   Sr>Sr?Sr@SrASrBSrCSrDSrESrFSrGSrHS rIS!rJS"rKS#rLS$rMSrNS%rOSrPS&\=S''   SrQS&\=S('   SrRS&\=S)'   S*rSS+rTS+rUS,rVS-\=S.'   S/rWS-\=S0'   S1rXS2rYS3rZS4/r[SS5 jr\SS6 jr]SSS7 jjr^\R                  \R                  \R                  \R                  \R                  S8.rdSS9 jreSS: jrfSS; jrgSS< jrhSS= jriSS> jrjSS? jrkSS@ jrlSSA jrmSSB jrnSSC jroSSD jrpSSE jrqSSF jrrSSG jrsSSH jrtSSI jruSSJ jrvSSK jrwSSL jrxSSM jrySSN jrzSSO jr{\|" / SPQ5      r}SSQ jr~      SSR jrSSS jrSST jrSSU jrSSV jrSSW jrSSX jrSSY jrSSZ jrSS[ jrSS\ jrSS] jrSS^ jr\|" / S_Q5      rSS` jrSSa jrSSb jrSSc jrSSd jrSeSf/0rSg\=Sh'   0 Si\_Sj\y_Sk\~_Sl\l_Sm\'_Sn\t_So\e_Sp\r_Sq\e_Sr\q_Ss\r_St\g_Su\k_Sv\v_Sw\m_Sx\x_Sy\{_0 Sz\m_S{\e_S|\e_S}\e_S~\s_S\t_Se\e_S\e_S\e_S\i_S\i_S\m_S\e_S\e_S\o_S\h_S\(_E\l\h\u\S.ErS\=S'   \e\\\e\h\i\e\\z\k\r\S.rS\=S'   \\\w\.\\m\m\\\S.
rS\=S'   SfSe0rS\=S'   0 rS\=S'   \GR1                  \5        \GR3                  5        H  u  rr\ H  r\\;  d  M  \\   \\'   M     M!     \GR;                  5       rS\=S'   \GR1                  \5        / SQrS\=S'   \|" Sk/5      rSS jr S       SS jjrSS jr S     SS jjrSS jrSS jr\|" / SQ5      r " S S5      r " S S\\\4   5      rSS jr " S S\\S4   5      rSS jrg)z9Functions and classes common to multiple pymongo modules.    )annotationsN)OrderedDictabc)get_close_matches)requiresversion)TYPE_CHECKINGAnyCallableIteratorMappingMutableMappingNoReturnOptionalSequenceTypeUnionoverload)unquote_plus)SON)UuidRepresentation)CodecOptionsDatetimeConversionTypeRegistry)RawBSONDocument)validate_compressorsvalidate_zlib_compression_level)
DriverInfo)ConfigurationError)_validate_event_listeners)ReadConcern)_MONGOS_MODES_ServerMode)	ServerApi)DEFAULT_WRITE_CONCERNWriteConcernvalidate_boolean)_AgnosticClientSessionzSequence[Type[Any]]ORDERED_TYPESi   i li z4.2      
         g      ?<   g      4@d      Optional[int]MAX_IDLE_TIME_MSMAX_IDLE_TIME_SECWAIT_QUEUE_TIMEOUT   T);   zSequence[int]COMMAND_NOT_FOUND_CODES)   i@  i@  UNAUTHORIZED_CODESi'  mongodbautoCANONICALIZE_HOST_NAMEc                    U nSnU R                  S5      nUS:w  a  U SU [        XS-   S 5      p!UR                  S5      (       a  USS nX4$ )z5Split a host:port string into (host, int(port)) pair.ii  :Nr-   [)rfindint
startswith)nodehostportidxs       ;/app/mltbenv/lib/python3.13/site-packages/pymongo/common.pypartition_noderJ      s\    DD
**S/C
by$3ZT')_!5dsAbz:    c                @    [        U 5      u  pUR                  5       U4$ )z6Split and normalize a node name from a hello response.)rJ   lower)rE   rF   rG   s      rI   
clean_noderN      s!    %JD ::<rK   c                b    SU  S3nU(       a  USSR                  U5       S3-  n[        U5      e)z1Raise ConfigurationError with the given key name.Unknown option: .z Did you mean one of (, z:) or maybe a camelCase version of one? Refer to docstring.)joinr   )keysuggestionsmsgs      rI   raise_config_errorrW      s=    SE
#C'		+(>'??yzz
S
!!rK   )unspecifiedstandardpythonLegacy
javaLegacycsharpLegacyc                v    [        U[        5      (       a  US;  a  [        SU  S35      eUS:H  $ [        X5      $ )z8Validates that value is True, False, 'true', or 'false'.)truefalseThe value of z must be 'true' or 'false'r^   )
isinstancestr
ValueErrorr'   optionvalues     rI   validate_boolean_or_stringrg      sB    %))}VH4NOPPF**rK   c                    [        U[        5      (       a  U$ [        U[        5      (       a   [        U5      $ [	        SU  S[        U5       35      e! [         a    [        SU  S35      Sef = f)zDValidates that 'value' is an integer (or basestring representation).r`   z must be an integerNWrong type for z , value must be an integer, not ra   rC   rb   rc   	TypeErrortyperd   s     rI   validate_integerrm      s{    %	E3			Tu: ofX-MdSXk][
\\  	T}VH4GHItS	Ts   
A A.c                F    [        X5      nUS::  a  [        SU  S35      eU$ )zFValidate that 'value' is a positive integer, which does not include 0.r   r`   z must be a positive integerrm   rc   re   rf   vals      rI   validate_positive_integerrr      s-    
6
)C
ax=0KLMMJrK   c                F    [        X5      nUS:  a  [        SU  S35      eU$ )z1Validate that 'value' is a positive integer or 0.r   r`   z must be a non negative integerro   rp   s      rI   validate_non_negative_integerrt      s-    
6
)C
Qw=0OPQQJrK   c                X    Uc  U$ [        X5      n[        U5      R                  5         U$ )z1Validates that 'value' is file-like and readable.)validate_stringopencloserd   s     rI   validate_readablery      s-    } F*EKLrK   c                "    Uc  U$ [        X5      $ )z4Validate that 'value' is a positive integer or None.rr   rd   s     rI   !validate_positive_integer_or_noner|      s    }$V33rK   c                "    Uc  U$ [        X5      $ )z9Validate that 'value' is a positive integer or 0 or None.)rt   rd   s     rI   %validate_non_negative_integer_or_noner~      s    }(77rK   c                d    [        U[        5      (       a  U$ [        SU  S[        U5       35      e)z/Validates that 'value' is an instance of `str`.ri   z(, value must be an instance of str, not )ra   rb   rk   rl   rd   s     rI   rv   rv      s5    %
ofX-UVZ[`VaUbc
ddrK   c                "    Uc  U$ [        X5      $ )z@Validates that 'value' is an instance of `basestring` or `None`.)rv   rd   s     rI   validate_string_or_noner     s    }6))rK   c                    [        U[        5      (       a  U$ [        U[        5      (       a   [        U5      $ [	        SU  S[        U5       35      e! [         a    Us $ f = f)/Validates that 'value' is an integer or string.ri   z,, value must be an integer or a string, not rj   rd   s     rI   validate_int_or_basestringr     sk    %	E3			u: 
&!MdSXk][   	L	s   
A A"!A"c                    [        U[        5      (       a  U$ [        U[        5      (       a   [        U5      n[	        X5      $ [        SU  S[        U5       35      e! [         a    Us $ f = f)r   ri   z9, value must be an non negative integer or a string, not )ra   rC   rb   rc   rt   rk   rl   rp   s      rI   'validate_non_negative_int_or_basestringr     sx    %	E3			e*C -V99

&!Z[_`e[fZgh   	L	s   A A-,A-c                    U  S3n [        U5      nSUs=:  a  S:  d  O  [        U  S35      eU$ ! [         a    [        U5      Se[         a    [        U5      Sef = f)zPValidates that 'value' is a float, or can be converted to one, and is
positive.
z must be an integer or floatNr   g    eAz1 must be greater than 0 and less than one billion)floatrc   rk   )re   rf   errmsgs      rI   validate_positive_floatr   %  sw     x34F*e u?s?F8#TUVVL  + d* *T)*s	   1 ,Ac                2    US:X  d  US:X  a  g[        X5      $ )z_Validates that 'value' is 0 or a positive float, or can be converted to
0 or a positive float.
r   0r   rd   s     rI   validate_positive_float_or_zeror   8  s     zUc\"611rK   c                (    Uc  U$ [        X5      S-  $ )[Validates a timeout specified in milliseconds returning
a value in floating point seconds.
     @@r   rd   s     rI   validate_timeout_or_noner   A  s     }"61F::rK   c                Z    Uc  [        U  S35      eUS:X  d  US:X  a  g[        X5      S-  $ )zValidates a timeout specified in milliseconds returning
a value in floating point seconds for the case where None is an error
and 0 is valid. Setting the timeout to nothing in the URI string is a
config error.
z cannot be Noner   r   r   )r   r   rd   s     rI   validate_timeout_or_zeror   J  s;     } F8?!;<<zUc\"61F::rK   c                >    Ub  US:X  d  US:X  a  g[        X5      S-  $ )zValidates a timeout specified in milliseconds returning
a value in floating point seconds. value=0 and value="0" are treated the
same as value=None which means unlimited timeout.
Nr   r   r   r   rd   s     rI    validate_timeout_or_none_or_zeror   W  s(    
 }
esl"61F::rK   c                &    Uc  g[        X5      S-  $ )r   Nr   )r   rd   s     rI   validate_timeoutmsr   a  s     }*69FBBrK   c                2    US:X  d  US:X  a  g[        X5      $ )zBValidates maxStalenessSeconds according to the Max Staleness Spec.r@   z-1r{   rd   s     rI   validate_max_stalenessr   j  s    {etm$V33rK   c                N    [        U[        5      (       d  [        U< S35      eU$ )zValidate a read preference.z is not a read preference)ra   r#   rk   dummyrf   s     rI   validate_read_preferencer   r  s'    e[))5)#<=>>LrK   c                6    U[         ;  a  [        U S35      eU$ )zValidate read preference mode for a MongoClient.

.. versionchanged:: 3.5
   Returns the original ``value`` instead of the validated read preference
   mode.
z is not a valid read preference)r"   rc   r   s     rI   validate_read_preference_moder   y  s$     M!E7"ABCCLrK   c                N    SSK Jn  X;  a  [        U  S[        U5       35      eU$ )z&Validate the authMechanism URI option.r   )
MECHANISMSz must be in )pymongo.auth_sharedr   rc   tuple)re   rf   r   s      rI   validate_auth_mechanismr     s,    .F8<j0A/BCDDLrK   c                n     [         U   $ ! [         a    [        U S[        [         5       35      Sef = f)z<Validate the uuid representation option selected in the URI.z3 is an invalid UUID representation. Must be one of N)_UUID_REPRESENTATIONSKeyErrorrc   r   r   s     rI   validate_uuid_representationr     sN    $U++ g *+,.
 		s    )4c                j   [        U[        5      (       d  U/n/ nU Hr  nUS:X  a  UR                  0 5        M   0 nUR                  S5       H-  nUR                  S5      u  pg[	        U5      U[	        U5      '   M/     UR                  U5        Mt     U$ ! [
         a    [        U< SU  35      Sef = f)z5Parse readPreferenceTags if passed as a client kwarg. ,r?   z not a valid value for N)ra   listappendsplitr   	Exceptionrc   )namerf   tag_setstag_settagstagrT   rq   s           rI   validate_read_preference_tagsr     s    eT""%'Hb=OOB	TD}}S)99S>*6s*;\#&' * OOD!  O  	T{*A$HItS	Ts   ABB2)SERVICE_NAMESERVICE_HOSTr=   SERVICE_REALMAWS_SESSION_TOKENENVIRONMENTTOKEN_RESOURCEc           	        0 n[        U[        5      (       Gd  [        U[        5      (       d  [        S[	        U5       35      eUR                  5        H  u  p1[        U[        5      (       a  XU'   M   [        U[        5      (       a  [        U5      R                  5       X#'   MR  US;   a  [        U[        5      (       a  XU'   Ms  US;   a3  SSK	J
n  [        X5      (       d  [        S[	        U5       35      eXU'   M  [        SU S[	        U5       35      e   U$ [        X5      n[        U5      nUR                  S	5       H}  nUR                  S
5      u  p6nU(       d  [        S5      eU[        ;  a.  SU;   a  [        S5      e[        U S[!        [        5       35      eUS:X  a  SSKJn  U" U5      X#'   My  XrU'   M     U$ )z!Validate authMechanismProperties.zIAuth mechanism properties must be given as a string or a dictionary, not )ALLOWED_HOSTS)OIDC_CALLBACKOIDC_HUMAN_CALLBACKr   )OIDCCallbackz-callback must be an OIDCCallback object, not z)Invalid type for auth mechanism property rR   r   r?   z#Malformed auth mechanism propertiesr   zPauth mechanism properties must be key:value pairs like AWS_SESSION_TOKEN:<token>z< is not a supported auth mechanism property. Must be one of r=   ) _validate_canonicalize_host_name)ra   rb   dictrc   rl   itemsboolrM   r   pymongo.auth_oidc_sharedr   rv   r   r   	partition_MECHANISM_PROPSr   r   r   )	re   rf   propsrT   r   opt_rq   r   s	            rI   "validate_auth_mechanism_propertiesr     s   EeS!!%&&[\`af\g[hi   ++-JC%%%"c
E4(( Z--/
))j.E.E"c
@@A!%66$'TUYZ_U`Ta%bcc"c
 #LSEQSTXY^T_S`!abb ( F*EE{{3mmC(BCC&&"c) E 
 % 6)*+-  **L9#>EJ#J/  2 LrK   c                   Sn [        U[        R                  5      nU(       d#  [        U[        5      (       d  [        U  S35      eU$ ! [         a8    [	        US5      (       a$  [        UR
                  [        R                  5      n Nmf = f)z#Validate the document_class option.F
__origin__zg must be dict, bson.son.SON, bson.raw_bson.RawBSONDocument, or a subclass of collections.MutableMapping)
issubclassr   r   rk   hasattrr   r   )re   rf   
is_mappings      rI   validate_document_classr     s     JJs'9'9:
 j@@h 5 5
 	

 L  J5,''#E$4$4c6H6HIJJs   A
 
?BBc                ^    Ub)  [        U[        5      (       d  [        U  S[         35      eU$ )z"Validate the type_registry option.z must be an instance of )ra   r   rk   rd   s     rI   validate_type_registryr     s0    E<!@!@6(":<.IJJLrK   c                b    [        U[        5      (       d  [        U  S[        U5       35      eU$ )z!Validates that 'value' is a list.z must be a list, not )ra   r   rk   rl   rd   s     rI   validate_listr     s/    eT""6("7U}EFFLrK   c                "    Uc  U$ [        X5      $ )z)Validates that 'value' is a list or None.)r   rd   s     rI   validate_list_or_noner     s    }''rK   c                j    [        U[        R                  [        45      (       d  [	        U  S35      eg)z/Validates that 'value' is a list or a document.zu must either be a list or an instance of dict, bson.son.SON, or any other type that inherits from collections.MappingN)ra   r   r   r   rk   rd   s     rI   validate_list_or_mappingr     s9    eckk4011h " "
 	
 2rK   c                ^    [        U[        R                  5      (       d  [        U  S35      eg)z=Validate the type of method arguments that expect a document.zd must be an instance of dict, bson.son.SON, or any other type that inherits from collections.MappingN)ra   r   r   rk   rd   s     rI   validate_is_mappingr   '  s4    eS[[))h " "
 	
 *rK   c                j    [        U[        R                  [        45      (       d  [	        U  S35      eg)zEValidate the type of method arguments that expect a MongoDB document.z must be an instance of dict, bson.son.SON, bson.raw_bson.RawBSONDocument, or a type that inherits from collections.MutableMappingN)ra   r   r   r   rk   rd   s     rI   validate_is_document_typer   1  s<    ec00/BCCh ) )
 	
 DrK   c                ~    Uc  U$ [        X5        [        UR                  S5      5      S:  a  [        U  S35      eU$ )zValidate the appname option.zutf-8   z must be <= 128 bytes)rv   lenencoderc   rd   s     rI   validate_appname_or_noner   <  sB    }F"
5<< !C'F8#89::LrK   c                V    Uc  U$ [        U[        5      (       d  [        U  S35      eU$ ) Validate the driver keyword arg.z" must be an instance of DriverInfo)ra   r   rk   rd   s     rI   validate_driver_or_noner   G  s1    }eZ((6("DEFFLrK   c                l    Uc  U$ [        U[        5      (       d  [        U  S[        U5       35      eU$ )z$Validate the server_api keyword arg.z' must be an instance of ServerApi, not )ra   r$   rk   rl   rd   s     rI   validate_server_api_or_noner   P  s9    }eY''6("I$u+WXXLrK   c                b    Uc  U$ [        U5      (       d  [        U  S[        U5       35      eU$ )z%Validates that 'value' is a callable.z must be a callable, not )callablerc   rl   rd   s     rI   validate_is_callable_or_noner   Y  s5    }E??F8#<T%[MJKKLrK   c                    [        SU 5        U (       aL  [        U [        5      (       d6  [        [	        U 5      5      nUR                  S5      (       a  [        S5      eggg)z Validate a replacement document.replacement$z'replacement can not include $ operatorsN)r   ra   r   nextiterrD   rc   )r   firsts     rI   validate_ok_for_replacer   b  sT    {3:k?CCT+&'C  FGG ! D{rK   c                    [        SU 5        U (       d  [        S5      e[        U [        5      (       + n[	        [        U 5      5      nU(       a"  UR                  S5      (       d  [        S5      egg)zValidate an update document.updatezupdate cannot be emptyr   z"update only works with $ operatorsN)r   rc   ra   r   r   r   rD   )r   is_documentr   s      rI   validate_ok_for_updater   l  s^    Xv.122 ..KfE5++C00=>> 1{rK   )strictreplaceignorec                T    U[         ;  a  [        U S[        [         5       35      eU$ )zAValidate the Unicode decode error handler option of CodecOptions.z< is an invalid Unicode decode error handler. Must be one of )_UNICODE_DECODE_ERROR_HANDLERSrc   r   r   s     rI   %validate_unicode_decode_error_handlerr   |  s:    22g 3457
 	

 LrK   c                f    Ub-  [        U[        R                  5      (       d  [        SU-  5      eU$ )zValidate the tzinfo optionz)%s must be an instance of datetime.tzinfo)ra   datetimetzinfork   r   s     rI   validate_tzinfor     s.    E8??!C!CCeKLLLrK   c                n    Uc  U$ SSK Jn  [        X5      (       d  [        U  S[	        U5       35      eU$ )r   r   )AutoEncryptionOptsz0 must be an instance of AutoEncryptionOpts, not )pymongo.encryption_optionsr  ra   rk   rl   )re   rf   r  s      rI   %validate_auto_encryption_opts_or_noner    s>    }=e006("RSWX]S^R_`aaLrK   c                (   Uc  [         R                  $ [        U[        5      (       a2  UR	                  5       (       a  [        [        U5      5      $ [         U   $ [        U[
        5      (       a  [        U5      $ [        U  S[        U5       35      e)z%Validate a DatetimeConversion string.z; must be a str or int representing DatetimeConversion, not )r   DATETIMEra   rb   isdigitrC   rk   rl   rd   s     rI   validate_datetime_conversionr    s~    }!***%==??%c%j11!%((	E3		!%((
(MdSXk][ rK   c                6    US;  a  [        U  SU< S35      eU$ )z)Validate the serverMonitoringMode option.>   r<   pollstream=z7 is invalid. Must be one of "auto", "stream", or "poll")rc   rd   s     rI   validate_server_monitoring_moder    s0    ..hay WX
 	
 LrK   tlssslzdict[str, list[str]]URI_OPTIONS_ALIAS_MAPappnameauthmechanismauthmechanismproperties
authsourcecompressorsconnecttimeoutmsdirectconnectionheartbeatfrequencymsjournallocalthresholdmsmaxidletimemsmaxconnectingmaxpoolsizemaxstalenesssecondsreadconcernlevelreadpreferencereadpreferencetags
replicaset
retryreadsretrywritesloadbalancedserverselectiontimeoutmssockettimeoutmstlsallowinvalidcertificatestlsallowinvalidhostnames	tlscafiletlscertificatekeyfiletlscertificatekeyfilepasswordtlsdisableocspendpointchecktlsinsecurew
wtimeoutmszlibcompressionlevel)srvservicenamesrvmaxhosts	timeoutmsservermonitoringmode$dict[str, Callable[[Any, Any], Any]]URI_OPTIONS_VALIDATOR_MAP)connectdriver
server_apifsyncminpoolsize
tlscrlfiletz_awareunicode_decode_error_handleruuidrepresentationwaitqueuemultiplewaitqueuetimeoutmsdatetime_conversionNONSPEC_OPTIONS_VALIDATOR_MAP)
document_classtype_registryread_preferenceevent_listenersr   usernamepasswordserver_selectorauto_encryption_optsauthoidcallowedhostsKW_VALIDATORSzdict[str, str]INTERNAL_URI_OPTION_NAME_MAPzdict[str, tuple[str, str]]URI_OPTIONS_DEPRECATION_MAP
VALIDATORS)r  r  r  r  r&  r'  rB  z	list[str]TIMEOUT_OPTIONSc                `    [        X5      u  p!U[        ;  a  [        SU  S[         35      eX4$ )z,Validate optional authentication parameters.rP   z. Must be in )validate_AUTH_OPTIONSr   )re   rf   rM   s      rI   validate_auth_optionrV  7  s7    F*LEM! #3F8=!XYY=rK   c                l    U=(       d    U n X   $ ! [          a    [        X!SS9n[        X5         g f = f)Ng?)cutoff)r   r   rW   )rT   
validators
normed_keyrU   s       rI   _get_validatorr[  ?  s?     "sJ-%% -'
sK3,-s    33c                R    [        U [        U R                  5       S9nU" X5      nX4$ )zGeneric validation function.rZ  )r[  rQ  rM   )re   rf   	validators      rI   rT  rT  J  s(    vzfllnMIf$E=rK   c                  ^ ^
 [        T [        5      (       a  [        5       nSS jnSU 4S jjnO0 nSS jnSS jnT R                  5        H/  u  pVU" U5      n [        U[        US9nU" XV5      n	XU" U5      '   M1     U$ ! [
        [        [        4 ae  m
US:X  a.  [        U
4S j[         5       5      (       a  S[        T
5      ;  a  e U(       a$  [        R                  " [        T
5      S	S
9   Sm
@
M  e Sm
@
ff = f)aI  Validate each entry in options and raise a warning if it is not valid.
Returns a copy of options with invalid entries removed.

:param opts: A dict containing MongoDB URI options.
:param warn: If ``True`` then warnings will be logged and
      invalid options will be ignored. Otherwise, invalid options will
      cause errors.
c                    U $ N xs    rI   get_normed_key-get_validated_options.<locals>.get_normed_key`      HrK   c                &   > TR                  U 5      $ ra  )	cased_key)rd  optionss    rI   get_setter_key-get_validated_options.<locals>.get_setter_keyc  s    $$Q''rK   c                "    U R                  5       $ ra  )rM   rc  s    rI   re  rf  i  s    779rK   c                    U $ ra  rb  rc  s    rI   rk  rl  l  rg  rK   r]  r  c              3  >   >#    U  H  o[        T5      ;   v   M     g 7fra  )rb   ).0pexcs     rI   	<genexpr>(get_validated_options.<locals>.<genexpr>w  s     E/D!SX/Ds   z*is not a supported auth mechanism propertyr1   )
stacklevelN)rd  rb   returnrb   )ra   _CaseInsensitiveDictionaryr   r[  r7  rc   rk   r   any_MECH_PROP_MUST_RAISErb   warningswarn)rj  r{  validated_optionsre  rk  r   rf   rZ  r^  	validatedrr  s   `         @rI   get_validated_optionsr~  Q  s     '56668		( 	( 		 mmo
#C(
	F&s,ER\]I!#-I =FnZ89# &$  I'9: 
	77E/DEEE@CPc#h155
	s   BC;AC65C66C;c                .    U R                  SSU S35      $ )NescCollectionenxcol_.z.escgetencrypted_fieldsr   s     rI   _esc_coll_namer    s    8D61FGGrK   c                .    U R                  SSU S35      $ )NecocCollectionr  z.ecocr  r  s     rI   _ecoc_coll_namer    s     0HTF%2HIIrK   )r/  wtimeoutr0  r;  jr  c                      \ rS rSrSr          SS jr\SS j5       r\SS j5       rSS jr	\SS j5       r
SS jr\SS	 j5       rS
rg)
BaseObjecti  zA base class that provides attributes and methods common
to multiple pymongo classes.

SHOULD NOT BE USED BY DEVELOPERS EXTERNAL TO MONGODB.
c                l   [        U[        5      (       d  [        S5      eXl        [        U[        5      (       d  [        U< S35      eX l        [        U[        5      (       d  [        S[        U5       35      eX0l        [        U[        5      (       d  [        S[        U5       35      eX@l
        g )NzDcodec_options must be an instance of bson.codec_options.CodecOptionszR is not valid for read_preference. See pymongo.read_preferences for valid options.zMwrite_concern must be an instance of pymongo.write_concern.WriteConcern, not zJread_concern must be an instance of pymongo.read_concern.ReadConcern, not )ra   r   rk   _codec_optionsr#   _read_preferencer&   rl   _write_concernr!   _read_concern)selfcodec_optionsrG  write_concernread_concerns        rI   __init__BaseObject.__init__  s     -66bcc+/;77"% &  
 !0-66_`der`s_tu  ,,44\]abn]o\pq  *rK   c                    U R                   $ )zTRead only access to the :class:`~bson.codec_options.CodecOptions`
of this instance.
)r  r  s    rI   r  BaseObject.codec_options  s    
 """rK   c                    U R                   $ )zRead only access to the :class:`~pymongo.write_concern.WriteConcern`
of this instance.

.. versionchanged:: 3.0
  The :attr:`write_concern` attribute is now read only.
)r  r  s    rI   r  BaseObject.write_concern  s     """rK   c                V    U(       a  UR                   (       a  [        $ U R                  $ )zBRead only access to the write concern of this instance or session.)in_transactionr%   r  r  sessions     rI   _write_concern_forBaseObject._write_concern_for  s!     w--((!!!rK   c                    U R                   $ )zRead only access to the read preference of this instance.

.. versionchanged:: 3.0
  The :attr:`read_preference` attribute is now read only.
)r  r  s    rI   rG  BaseObject.read_preference  s     $$$rK   c                n    U(       a#  UR                  5       =(       d    U R                  $ U R                  $ )zDRead only access to the read preference of this instance or session.)_txn_read_preferencer  r  s     rI   _read_preference_forBaseObject._read_preference_for  s-     //1JT5J5JJ$$$rK   c                    U R                   $ )zlRead only access to the :class:`~pymongo.read_concern.ReadConcern`
of this instance.

.. versionadded:: 3.2
)r  r  s    rI   r  BaseObject.read_concern  s     !!!rK   )r  r  r  r  N)
r  CodecOptions[Any]rG  r#   r  r&   r  r!   rv  None)rv  r  )rv  r&   )r   Optional[_AgnosticClientSession]rv  r&   )rv  r#   )r  r  rv  r#   )rv  r!   )__name__
__module____qualname____firstlineno____doc__r  propertyr  r  r  rG  r  r  __static_attributes__rb  rK   rI   r  r    s    *(* %* $	*
 "* 
*> # # # #" % %% " "rK   r  c                      \ rS rSrSS jrSS jrSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jrSS S jjrS!S jrS"S jrS#S jr\SS$S jj5       r\S%S j5       rSS&S jjrS'S jrSS jrSrg)(rw  i  c                T    0 U l         0 U l        U R                  [        U0 UD65        g ra  )%_CaseInsensitiveDictionary__casedkeys _CaseInsensitiveDictionary__datar   r   )r  argskwargss      rI   r  #_CaseInsensitiveDictionary.__init__  s'    +-&(D$)&)*rK   c                <    UR                  5       U R                  ;   $ ra  )rM   r  r  rT   s     rI   __contains__'_CaseInsensitiveDictionary.__contains__  s    yy{dkk))rK   c                ,    [        U R                  5      $ ra  )r   r  r  s    rI   __len__"_CaseInsensitiveDictionary.__len__  s    4;;rK   c                (    S U R                    5       $ )Nc              3  $   #    U  H  ov   M     g 7fra  rb  )rp  rT   s     rI   rs  6_CaseInsensitiveDictionary.__iter__.<locals>.<genexpr>  s     0//s   )r  r  s    rI   __iter__#_CaseInsensitiveDictionary.__iter__  s    0t//00rK   c                x    [        U  Vs0 s H  oR                  U   U R                  U   _M!     sn5      $ s  snf ra  )rb   r  r  )r  ks     rI   __repr__#_CaseInsensitiveDictionary.__repr__  s5    FA$$Q'Q7FGGFs   &7c                \    UR                  5       nXR                  U'   X R                  U'   g ra  rM   r  r  )r  rT   rf   lc_keys       rI   __setitem__&_CaseInsensitiveDictionary.__setitem__  s'    #& #FrK   c                <    U R                   UR                  5          $ ra  )r  rM   r  s     rI   __getitem__&_CaseInsensitiveDictionary.__getitem__  s    {{399;''rK   c                X    UR                  5       nU R                  U	 U R                  U	 g ra  r  )r  rT   r  s      rI   __delitem__&_CaseInsensitiveDictionary.__delitem__  s'    V$KKrK   c                    [        U[        R                  5      (       d  [        $ [	        U 5      [	        U5      :w  a  gU H  nX   X   :w  d  M    g   g)NFT)ra   r   r   NotImplementedr   r  otherrT   s      rI   __eq__!_CaseInsensitiveDictionary.__eq__  sJ    %--!!t9E
"CyEJ&  rK   Nc                V    U R                   R                  UR                  5       U5      $ ra  )r  r  rM   r  rT   defaults      rI   r  _CaseInsensitiveDictionary.get  s    {{syy{G44rK   c                    UR                  5       nU R                  R                  US 5        U R                  R                  " U/UQ70 UD6$ ra  )rM   r  popr  )r  rT   r  r  r  s        rI   r  _CaseInsensitiveDictionary.pop  s@    VT*{{v7777rK   c                v    U R                   R                  5       u  pU R                  R                  U5      nX#4$ ra  )r  popitemr  r  )r  r  ri  rf   s       rI   r  "_CaseInsensitiveDictionary.popitem  s4     ,,446'rK   c                l    U R                   R                  5         U R                  R                  5         g ra  )r  clearr  r  s    rI   r   _CaseInsensitiveDictionary.clear  s$     rK   c                    g ra  rb  r  s      rI   
setdefault%_CaseInsensitiveDictionary.setdefault#      rK   c                    g ra  rb  r  s      rI   r  r  '  r  rK   c                    UR                  5       nX;   a  U R                  U   $ XR                  U'   X R                  U'   U$ ra  )rM   r  r  )r  rT   r  r  s       rI   r  r  +  s@    ;;;v&&'*V$")KKNrK   c                    [        U[        5      (       a  U H  nX   XR                  U5      '   M     g U H	  nX   X'   M     g ra  )ra   rw  ri  r  s      rI   r   !_CaseInsensitiveDictionary.update4  sB    e788-2Z__S)*  !J	 rK   c                <    U R                   UR                  5          $ ra  )r  rM   r  s     rI   ri  $_CaseInsensitiveDictionary.cased_key<  s    		,,rK   )__casedkeys__data)r  r
   r  r
   )rT   rb   rv  r   )rv  rC   )rv  zIterator[str]rv  rb   )rT   rb   rf   r
   rv  r  )rT   rb   rv  r
   )rT   rb   rv  r  )r  r
   rv  r   ra  )rT   rb   r  Optional[Any]rv  r
   )rT   rb   r  r
   r  r
   rv  r
   )rv  tuple[str, Any])rv  r  )rT   rb   r  r  rv  r  )rT   rb   r  r
   rv  r
   )rT   rb   r  r  rv  r  )r  Mapping[str, Any]rv  r  )r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r   ri  r  rb  rK   rI   rw  rw    s{    +
* 1H$
( 
	58
 
    '-rK   rw  c                 2     SSK Jn   g! [         a     gf = f)zIs the C extension installed?r   	_cmessageTF)pymongor  ImportErrorr  s    rI   has_cr   @  s    % s   	 
c                     ^  \ rS rSrSrS
U 4S jjr\SSS jj5       r\SS j5       r\SS j5       r	SS jr
SS jrS	rU =r$ )VersioniJ  z4A class that can be used to compare version strings.c                Z   > U R                  US5      n[        TU ]	  U [        U5      5      $ )N   )_paddedsuper__new__r   )clsr   padded_version	__class__s      rI   r  Version.__new__M  s)    Wa0wsE.$9::rK   c                    [        U5      n[        U5      U:  a/  [        U[        U5      -
  5       H  nUR                  U5        M     U$ ra  )r   r   ranger   )r  r   lengthpaddingas_listr   s         rI   r  Version._paddedQ  s@    t*w<& 6CL01w' 2rK   c                H   SnSnUR                  S5      (       a  USS nSnO;UR                  S5      (       a  USS nSnOUR                  S5      (       a  USS nSnS	U;   a  USUR                  S	5       nSnS
U;   a  USUR                  S
5       nSnOSU;   a  USUR                  S5       nSnSnUR                  S5       Vs/ s H  n[        U5      PM     nnU R	                  US5      nU(       a  US==   S-  ss'   UR
                  " U5        [        U6 $ s  snf )Nr   F+r@   r-   z-pre--z.devz-rcTrQ      )endswithfindr   rC   r  r   r  )r  version_stringmodbump_patch_levelpartr   s         rI   from_stringVersion.from_stringY  sJ    ""3''+Ab1NC$$W--+Ab1NC$$S))+Ab1NC^#+A0C0CF0KLNCN"+A0C0CE0JKNCN"+A0C0CC0HINC#)7)=)=c)BC)B3t9)BC++gq) BK1Ks   Ds   Dc                h    [        U5      nUS   S:  a  SUS'   U R                  US5      n[        U6 $ )Nr@   r   r  )r   r  r  )r  version_arrayr   s      rI   from_version_arrayVersion.from_version_array  s;    }%2;?GBK++gq)  rK   c                    U [        U6 :  $ ra  )r  )r  other_versions     rI   at_leastVersion.at_least  s    w...rK   c                @    SR                  [        [        U 5      5      $ )NrQ   )rS   maprb   r  s    rI   __str__Version.__str__  s    xxC''rK   rb  )r   rC   rv  r  )r   )r   r
   r  rC   r  rC   rv  z	list[int])r  rb   rv  r  )r   r
   rv  r  )r$  r
   rv  r   r  )r  r  r  r  r  r  classmethodr  r  r!  r%  r)  r  __classcell__)r
  s   @rI   r  r  J  sW    >;   %! %!N ! !/( (rK   r  .c                ^   [        U 5      n[        R                  U5      n[        S5      nUc   eU Vs/ s H  oDR	                  U 5      (       d  M  UPM     snS   nSU;   a  UR                  S5      S   nXUR                  S5      S-   S nU[        R                  U5      :  nXU4$ s  snf )z<Test whether an installed package is of the desired version.r  Nr   ;z>=r1   )r   r  r  r   rD   r   r  )package_namepackage_version_strpackage_versionrequirementsirequirementrequired_versionis_valids           rI   check_for_min_versionr7    s    !,/))*=>O
 I&L###*Illl<.H1lI!LK
k!'',Q/"#3#3D#9A#=#?@'"5"56F"GGH(:: Js   B*B*)rE   rb   rv  ztuple[str, int]ra  )rT   rb   rU   zOptional[list[str]]rv  r   )re   rb   rf   r
   rv  r   )re   rb   rf   r
   rv  rC   )re   rb   rf   r
   rv  Optional[str])re   rb   rf   r
   rv  r2   )re   rb   rf   r
   rv  rb   )re   rb   rf   r
   rv  Union[int, str])re   r
   rf   r
   rv  r9  )re   rb   rf   r
   rv  r   )re   rb   rf   r
   rv  Optional[float])re   r
   rf   r
   rv  r:  )r   r
   rf   r
   rv  r#   )r   r
   rf   r
   rv  rC   )r   rb   rf   r
   rv  zlist[dict[str, str]])re   rb   rf   r
   rv  zdict[str, Union[bool, str]])re   rb   rf   r
   rv  z<Union[Type[MutableMapping[str, Any]], Type[RawBSONDocument]])re   r
   rf   r
   rv  zOptional[TypeRegistry])re   rb   rf   r
   rv  z	list[Any])re   r
   rf   r
   rv  zOptional[list[Any]])re   r
   rf   r
   rv  r  )re   rb   rf   r
   rv  r  )re   r
   rf   r
   rv  zOptional[DriverInfo])re   r
   rf   r
   rv  zOptional[ServerApi])re   r
   rf   r
   rv  zOptional[Callable[..., Any]])r   r  rv  r  )r   r
   rv  r  )r   r
   rf   rb   rv  rb   )r   r
   rf   r
   rv  zOptional[datetime.tzinfo])re   r
   rf   r
   rv  r  )re   r
   rf   r
   rv  zOptional[DatetimeConversion])re   rb   rf   rb   rv  rb   )re   rb   rf   r
   rv  r  )rT   rb   rY  r6  rZ  r8  rv  zCallable[[Any, Any], Any])T)rj  r  r{  r   rv  zMutableMapping[str, Any])r  r  r   rb   rv  r
   )rv  r   )r/  rb   rv  ztuple[str, str, bool])r  
__future__r   r   rz  collectionsr   r   difflibr   importlib.metadatar   r   typingr	   r
   r   r   r   r   r   r   r   r   r   r   urllib.parser   bsonr   bson.binaryr   bson.codec_optionsr   r   r   bson.raw_bsonr   pymongo.compression_supportr   r   pymongo.driver_infor   pymongo.errorsr   pymongo.monitoringr    pymongo.read_concernr!   pymongo.read_preferencesr"   r#   pymongo.server_apir$   pymongo.write_concernr%   r&   r'   pymongo.typingsr(   r)   __annotations__MAX_BSON_SIZEMAX_MESSAGE_SIZEMIN_WIRE_VERSIONMAX_WIRE_VERSIONMAX_WRITE_BATCH_SIZEMIN_SUPPORTED_SERVER_VERSIONMIN_SUPPORTED_WIRE_VERSIONMAX_SUPPORTED_WIRE_VERSIONHEARTBEAT_FREQUENCYKILL_CURSOR_FREQUENCYEVENTS_QUEUE_FREQUENCYSERVER_SELECTION_TIMEOUTMIN_HEARTBEAT_INTERVALMIN_SRV_RESCAN_INTERVALCONNECT_TIMEOUTMAX_POOL_SIZEMIN_POOL_SIZEMAX_CONNECTINGr3   r4   r5   LOCAL_THRESHOLD_MSRETRY_WRITESRETRY_READSr8   r:   _MAX_END_SESSIONSSRV_SERVICE_NAMESERVER_MONITORING_MODEry  rJ   rN   rW   UNSPECIFIEDSTANDARDPYTHON_LEGACYJAVA_LEGACYCSHARP_LEGACYr   rg   rm   rr   rt   ry   r|   r~   rv   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   	frozensetr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r7  rD  rN  rO  rP  r   r   optnamealiasesaliascopyrQ  rR  rU  rV  r[  rT  r~  r  r  WRITE_CONCERN_OPTIONSr  rb   rw  r   r   rC   r  r7  rb  rK   rI   <module>rr     s    @ "   ( % 0    &  * M M ) + - 8 , ? ( W W6 '*;%7" 7 #      %                    #' - & $( = ' %) M (     */  . %7 M 6        22 	" &11"++&44$00&44 +	]48e*&2;
;;C4		* 
 4nA*(


H
? "++J!K 	" 
E7/ + 'C''C,'C A'C /	'C
 ''C 8'C 2'C 4'C )'C 7'C -'C .'C 8'C 1'C /'C  3!'C" 7#'C$ )%'C& ,''C( -)'C* .+'C,  8-'C. 7/'C0 
%1'C2 "#=3'C4  :5'C6 "7'C8 .9'C: $%<;'C< "#=='C> -?'C@ 	0A'CB /C'CD ;E'CF &0#;M'C ? 'X *%-'0#*$I6>27G C & .+/0''3A)73 $ 
50 n 	; 7 	     !> ?-335GW11/H/Q%e,  6 4M3Q3Q3S
0 S 
  -    456 ]a-	->-LY-- .200&*00fHJ
 ""Z[ U" U"pU-S!9 U-pC(eCHo C(L;rK   