
    nh                       U d Z ddlmZ ddlZddlZddlmZmZ ddlm	Z	 ddl
mZmZmZmZmZmZmZmZmZmZmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZmZm Z  ddl!m"Z" ddl#m$Z$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/m0Z0 ddl1m2Z2 ddl3m4Z4m5Z5m6Z6 erddl7m8Z8 eefZ9de:d<   dZ;dZ<dZ=dZ>dZ?dZ@dZAdZBdZCdZDdZEdZFd ZGd!ZHd"ZId#ZJdZKd$ZLdZMd%e:d&<   dZNd%e:d'<   dZOd%e:d(<   d)ZPd*ZQd*ZRd+ZSd,e:d-<   d.ZTd,e:d/<   d0ZUd1ZVd2ZWd3gZXdd4ZYdd5ZZddd6Z[ej                  ej                  ej                  ej                  ej                  d7Zadd8Zbdd9Zcdd:Zddd;Zedd<Zfdd=Zgdd>Zhdd?Zidd@ZjddAZkddBZlddCZmddDZnddEZoddFZpddGZqddHZrddIZsddJZtddKZuddLZvddMZwddNZx eyg dO      ZzddPZ{	 	 	 	 	 	 ddQZ|ddRZ}ddSZ~ddTZddUZddVZddWZddXZddYZddZZdd[Zdd\Zdd]Z eyg d^      Zdd_Zdd`ZddaZddbZddcZdddegiZdfe:dg<   i dhedievdje{dkeidle$dmeqdnebdoeodpebdqendreodseddtehduesdvejdweudxexi dyejdzebd{ebd|ebd}epd~eqddebdebdebdefdefdejdebdebdeldeede%eieeeredZde:d<   ebeeebeeefebeeweheoedZde:d<   e|e}ete+eejejeee~d
Zde:d<   deddiZde:d<   i Zde:d<   ej+                  e       ej-                         D ]  \  ZZeD ]  Zeevsee   ee<     ej5                         Zde:d<   ej+                  e       g dZde:d<    eydjg      ZddZ	 d	 	 	 	 	 	 	 ddZddZ	 d	 	 	 	 	 ddZddZddZ eyg d      Z G d d      Z G d deeef         ZddZy)z9Functions and classes common to multiple pymongo modules.    )annotationsN)OrderedDictabc)get_close_matches)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]ORDERED_TYPESi   i li z4.0      
         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                    | }d}| j                  d      }|dk7  r| d| t        | |dz   d       }}|j                  d      r|dd }||fS )z5Split a host:port string into (host, int(port)) pair.ii  :Nr+   [)rfindint
startswith)nodehostportidxs       t/var/www/html/SchoolMeal/SchoolMeal/pds_admin_SchoolMeal/Backend/venv/lib/python3.12/site-packages/pymongo/common.pypartition_noderH      s_    DD
**S/C
by$3ZT#')_!5dsAbz:    c                B    t        |       \  }}|j                         |fS )z6Split and normalize a node name from a hello response.)rH   lower)rC   rD   rE   s      rG   
clean_noderL      s#    %JD$ ::<rI   c                X    d|  d}|r|ddj                  |       dz  }t        |      )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      rG   raise_config_errorrU      s=    SE
#C'		+(>'??yzz
S
!!rI   )unspecifiedstandardpythonLegacy
javaLegacycsharpLegacyc                j    t        |t              r|dvrt        d|  d      |dk(  S t        | |      S )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     rG   validate_boolean_or_stringre      sA    %))}VH4NOPPFE**rI   c                    t        |t              r|S t        |t              r	 t        |      S t	        d|  dt        |             # t        $ r t        d|  d      dw xY w)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 r_   rA   r`   ra   	TypeErrortyperb   s     rG   validate_integerrk      su    %	E3		Tu: ofX-MdSXk][
\\  	T}VH4GHItS	Ts   
A	 	A#c                F    t        | |      }|dk  rt        d|  d      |S )zFValidate that 'value' is a positive integer, which does not include 0.r   r^   z must be a positive integerrk   ra   rc   rd   vals      rG   validate_positive_integerrp      s/    
65
)C
ax=0KLMMJrI   c                F    t        | |      }|dk  rt        d|  d      |S )z1Validate that 'value' is a positive integer or 0.r   r^   z must be a non negative integerrm   rn   s      rG   validate_non_negative_integerrr      s/    
65
)C
Qw=0OPQQJrI   c                X    ||S t        | |      }t        |      j                          |S )z1Validates that 'value' is file-like and readable.)validate_stringopencloserb   s     rG   validate_readablerw      s/    } FE*EKLrI   c                "    ||S t        | |      S )z4Validate that 'value' is a positive integer or None.rp   rb   s     rG   !validate_positive_integer_or_nonerz      s    }$VU33rI   c                "    ||S t        | |      S )z9Validate that 'value' is a positive integer or 0 or None.)rr   rb   s     rG   %validate_non_negative_integer_or_noner|      s    }(77rI   c                Z    t        |t              r|S t        d|  dt        |             )z/Validates that 'value' is an instance of `str`.rg   z(, value must be an instance of str, not )r_   r`   ri   rj   rb   s     rG   rt   rt      s2    %
ofX-UVZ[`VaUbc
ddrI   c                "    ||S t        | |      S )z@Validates that 'value' is an instance of `basestring` or `None`.)rt   rb   s     rG   validate_string_or_noner      s    }65))rI   c                    t        |t              r|S t        |t              r	 t        |      S t	        d|  dt        |             # t        $ r |cY S w xY w)/Validates that 'value' is an integer or string.rg   z,, value must be an integer or a string, not rh   rb   s     rG   validate_int_or_basestringr     se    %	E3		u: 
&!MdSXk][   	L	s   
A	 	AAc                    t        |t              r|S t        |t              r	 t        |      }t	        | |      S t        d|  dt        |             # t        $ r |cY S w xY w)r   rg   z9, value must be an non negative integer or a string, not )r_   rA   r`   ra   rr   ri   rj   rn   s      rG   'validate_non_negative_int_or_basestringr     st    %	E3		e*C -VS99

&!Z[_`e[fZgh   	L	s   A A#"A#c                    |  d}	 t        |      }d|cxk  rdk  sn t        |  d      |S # t        $ r t        |      dt        $ r t        |      dw xY w)zXValidates 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)floatra   ri   )rc   rd   errmsgs      rG   validate_positive_floatr   $  sw     x34F*e u?s?F8#TUVVL  + d* *T)*s	   / *Ac                0    |dk(  s|dk(  ryt        | |      S )zgValidates that 'value' is 0 or a positive float, or can be converted to
    0 or a positive float.
    r   0r   rb   s     rG   validate_positive_float_or_zeror   7  s!     zUc\"6511rI   c                (    ||S t        | |      dz  S )cValidates a timeout specified in milliseconds returning
    a value in floating point seconds.
         @@r   rb   s     rG   validate_timeout_or_noner   @  s      }"651F::rI   c                V    |t        |  d      |dk(  s|dk(  ryt        | |      dz  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   rb   s     rG   validate_timeout_or_zeror   I  s=     } F8?!;<<zUc\"651F::rI   c                :    |
|dk(  s|dk(  ryt        | |      dz  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   rb   s     rG    validate_timeout_or_none_or_zeror   V  s*    
 }
esl"651F::rI   c                &    |yt        | |      dz  S )r   Nr   )r   rb   s     rG   validate_timeoutmsr   `  s     }*659FBBrI   c                0    |dk(  s|dk(  ryt        | |      S )zBValidates maxStalenessSeconds according to the Max Staleness Spec.r>   z-1ry   rb   s     rG   validate_max_stalenessr   i  s    {etm$VU33rI   c                B    t        |t              st        |d      |S )zValidate a read preference.z is not a read preference)r_   r!   ri   dummyrd   s     rG   validate_read_preferencer   q  s$    e[)5)#<=>>LrI   c                2    |t         vrt        | d      |S )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    ra   r   s     rG   validate_read_preference_moder   x  s$     M!E7"ABCCLrI   c                L    ddl m} ||vrt        |  dt        |             |S )z&Validate the authMechanism URI option.r   )
MECHANISMSz must be in )pymongo.auth_sharedr   ra   tuple)rc   rd   r   s      rG   validate_auth_mechanismr     s.    .JF8<j0A/BCDDLrI   c                l    	 t         |   S # t        $ r t        | dt        t                      dw xY w)z<Validate the uuid representation option selected in the URI.z3 is an invalid UUID representation. Must be one of N)_UUID_REPRESENTATIONSKeyErrorra   r   r   s     rG   validate_uuid_representationr     sN    $U++ g *+,.
 		s    (3c                R   t        |t              s|g}g }|D ]n  }|dk(  r|j                  i        	 i }|j                  d      D ]-  }|j                  d      \  }}t	        |      |t	        |      <   / |j                  |       p |S # t
        $ r t        |d|        dw xY w)z5Parse readPreferenceTags if passed as a client kwarg. ,r=   z not a valid value for N)r_   listappendsplitr   	Exceptionra   )namerd   tag_setstag_settagstagrR   ro   s           rG   validate_read_preference_tagsr     s    eT"H Tb=OOB	TD}}S) <99S>S*6s*;\#&'< OOD!T O  	T{*A$HItS	Ts   ABB&)SERVICE_NAMESERVICE_HOSTr;   SERVICE_REALMAWS_SESSION_TOKENENVIRONMENTTOKEN_RESOURCEc           	     <   i }t        |t              st        |t              st        dt	        |             |j                         D ]  \  }}t        |t              r|||<   t        |t              rt        |      j                         ||<   I|dv rt        |t              r|||<   c|dv r/ddl	m
} t        ||      st        dt	        |             |||<   t        d| dt	        |              |S t        | |      }t        |      }|j                  d	      D ]t  }|j                  d
      \  }}}|st        d      |t        vr,d|v rt        d      t        | dt!        t                     |dk(  rddlm}  ||      ||<   p|||<   v |S )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 rP   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)r_   r`   dictra   rj   itemsboolrK   r   pymongo.auth_oidc_sharedr   rt   r   r   	partition_MECHANISM_PROPSr   r   r   )	rc   rd   propsrR   r   opt_ro   r   s	            rG   "validate_auth_mechanism_propertiesr     s   EeS!%&[\`af\g[hi   ++- 	cJC%%"c
E4( Z--/c
))j.E"c
@@A!%6$'TUYZ_U`Ta%bcc"c
 #LSEQSTXY^T_S`!abb	c FE*EE{{3 mmC(QBCC&&"c) E 
 % 6)*+-  **L9#>E#JE#J/2 LrI   c                    d}	 t        |t        j                        }|st        |t              st        |  d      |S # t        $ r3 t	        |d      r$t        |j
                  t        j                        }Y ]w xY w)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   ri   hasattrr   r   )rc   rd   
is_mappings      rG   validate_document_classr     s     JJs'9'9:
 j@h 5 5
 	

 L  J5,'#E$4$4c6H6HIJJs   A   9A<;A<c                R    |$t        |t              st        |  dt               |S )z"Validate the type_registry option.z must be an instance of )r_   r   ri   rb   s     rG   validate_type_registryr     s-    E<!@6(":<.IJJLrI   c                X    t        |t              st        |  dt        |             |S )z!Validates that 'value' is a list.z must be a list, not )r_   r   ri   rj   rb   s     rG   validate_listr     s,    eT"6("7U}EFFLrI   c                "    ||S t        | |      S )z)Validates that 'value' is a list or None.)r   rb   s     rG   validate_list_or_noner     s    }''rI   c                `    t        |t        j                  t        f      st	        |  d      y)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)r_   r   r   r   ri   rb   s     rG   validate_list_or_mappingr     s6    eckk401h " "
 	
 2rI   c                T    t        |t        j                        st        |  d      y)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)r_   r   r   ri   rb   s     rG   validate_is_mappingr   &  s1    eS[[)h " "
 	
 *rI   c                `    t        |t        j                  t        f      st	        |  d      y)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)r_   r   r   r   ri   rb   s     rG   validate_is_document_typer   0  s9    ec00/BCh ) )
 	
 DrI   c                |    ||S t        | |       t        |j                  d            dkD  rt        |  d      |S )zValidate the appname option.zutf-8   z must be <= 128 bytes)rt   lenencodera   rb   s     rG   validate_appname_or_noner   ;  sD    }FE"
5<< !C'F8#89::LrI   c                J    ||S t        |t              st        |  d      |S ) Validate the driver keyword arg.z" must be an instance of DriverInfo)r_   r   ri   rb   s     rG   validate_driver_or_noner   F  s.    }eZ(6("DEFFLrI   c                `    ||S t        |t              st        |  dt        |             |S )z$Validate the server_api keyword arg.z' must be an instance of ServerApi, not )r_   r"   ri   rj   rb   s     rG   validate_server_api_or_noner   O  s6    }eY'6("I$u+WXXLrI   c                V    ||S t        |      st        |  dt        |             |S )z%Validates that 'value' is a callable.z must be a callable, not )callablera   rj   rb   s     rG   validate_is_callable_or_noner   X  s3    }E?F8#<T%[MJKKLrI   c                    t        d|        | rBt        | t              s1t        t	        |             }|j                  d      rt        d      yyy)z Validate a replacement document.replacement$z'replacement can not include $ operatorsN)r   r_   r   nextiterrB   ra   )r   firsts     rG   validate_ok_for_replacer   a  sN    {3:k?CT+&'C FGG ! D{rI   c                    t        d|        | st        d      t        | t               }t	        t        |             }|r|j                  d      st        d      yy)zValidate an update document.updatezupdate cannot be emptyr   z"update only works with $ operatorsN)r   ra   r_   r   r   r   rB   )r   is_documentr   s      rG   validate_ok_for_updater   k  s[    Xv.122 ..KfE5++C0=>> 1{rI   )strictreplaceignorec                P    |t         vrt        | dt        t                      |S )zAValidate the Unicode decode error handler option of CodecOptions.z< is an invalid Unicode decode error handler. Must be one of )_UNICODE_DECODE_ERROR_HANDLERSra   r   r   s     rG   %validate_unicode_decode_error_handlerr   {  s:    22g 3457
 	

 LrI   c                Z    |(t        |t        j                        st        d|z        |S )zValidate the tzinfo optionz)%s must be an instance of datetime.tzinfo)r_   datetimetzinfori   r   s     rG   validate_tzinfor     s+    E8??!CCeKLLLrI   c                d    ||S ddl m} t        ||      st        |  dt	        |             |S )r   r   )AutoEncryptionOptsz0 must be an instance of AutoEncryptionOpts, not )pymongo.encryption_optionsr   r_   ri   rj   )rc   rd   r   s      rG   %validate_auto_encryption_opts_or_noner    s>    }=e/06("RSWX]S^R_`aaLrI   c                   |t         j                  S t        |t              r-|j	                         rt        t        |            S t         |   S t        |t
              rt        |      S t        |  dt        |             )z%Validate a DatetimeConversion string.z; must be a str or int representing DatetimeConversion, not )r   DATETIMEr_   r`   isdigitrA   ri   rj   rb   s     rG   validate_datetime_conversionr    sv    }!***%==?%c%j11!%((	E3	!%((
(MdSXk][ rI   c                0    |dvrt        |  d|d      |S )z)Validate the serverMonitoringMode option.>   r:   pollstream=z7 is invalid. Must be one of "auto", "stream", or "poll")ra   rb   s     rG   validate_server_monitoring_moder    s0    ..hay WX
 	
 LrI   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%  r@  z	list[str]TIMEOUT_OPTIONSc                b    t        | |      \  }}|t        vrt        d|  dt               | |fS )z,Validate optional authentication parameters.rN   z. Must be in )validate_AUTH_OPTIONSr   )rc   rd   rK   s      rG   validate_auth_optionrT  6  s=    FE*LE5M! #3F8=!XYY5=rI   c                l    |xs | }	 ||   S # t         $ r t        ||d      }t        | |       Y y w xY w)Ng?)cutoff)r   r   rU   )rR   
validators
normed_keyrS   s       rG   _get_validatorrY  >  sE     "sJ-*%% -'
JsK3,-s    #33c                \    t        | t        | j                               } || |      }| |fS )zGeneric validation function.rX  )rY  rO  rK   )rc   rd   	validators      rG   rR  rR  I  s,    vzfllnMIfe$E5=rI   c                   
 t         t              rt               }dd}d fd}n
i }dd}dd} j                         D ]4  \  }} ||      }	 t        |t        |      } |||      }	|	| ||      <   6 |S # t
        t        t        f$ rY
|dk(  r&t        
fdt        D              rdt        
      vr |r!t        j                  t        
      d	
       n Y d

d

ww xY w)aa  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                    | S N xs    rG   get_normed_keyz-get_validated_options.<locals>.get_normed_key_      HrI   c                &    j                  |       S r_  )	cased_key)rb  optionss    rG   get_setter_keyz-get_validated_options.<locals>.get_setter_keyb  s    $$Q''rI   c                "    | j                         S r_  )rK   ra  s    rG   rc  z-get_validated_options.<locals>.get_normed_keyh  s    779rI   c                    | S r_  r`  ra  s    rG   rh  z-get_validated_options.<locals>.get_setter_keyk  rd  rI   r[  r  c              3  8   K   | ]  }|t              v   y wr_  )r`   ).0pexcs     rG   	<genexpr>z(get_validated_options.<locals>.<genexpr>v  s     E!SXEs   z*is not a supported auth mechanism propertyr/   )
stacklevelN)rb  r`   returnr`   )r_   _CaseInsensitiveDictionaryr   rY  r5  ra   ri   r   any_MECH_PROP_MUST_RAISEr`   warningswarn)rg  rv  validated_optionsrc  rh  r   rd   rX  r\  	validatedrn  s   `         @rG   get_validated_optionsry  P  s     '5668		( 		 mmo F
U#C(
	F&s,ER\]I!#u-I =FnZ89#F$  I'9: 
	77E/DEE@CPc#h15 6
	s   A;;C(AC##C(c                .    | j                  dd| d      S )NescCollectionenxcol_.z.escgetencrypted_fieldsr   s     rG   _esc_coll_namer    s    8D61FGGrI   c                .    | j                  dd| d      S )NecocCollectionr|  z.ecocr}  r  s     rG   _ecoc_coll_namer    s     0HTF%2HIIrI   )r-  wtimeoutr.  r9  jr  c                      e Zd ZdZ	 	 	 	 	 	 	 	 	 	 d
dZedd       Zedd       ZddZedd       Z	ddZ
edd       Zy	)
BaseObjectzA base class that provides attributes and methods common
    to multiple pymongo classes.

    SHOULD NOT BE USED BY DEVELOPERS EXTERNAL TO MONGODB.
    c                J   t        |t              st        d      || _        t        |t              st        |d      || _        t        |t              st        dt        |             || _        t        |t              st        dt        |             || _
        y )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 )r_   r   ri   _codec_optionsr!   _read_preferencer$   rj   _write_concernr   _read_concern)selfcodec_optionsrE  write_concernread_concerns        rG   __init__zBaseObject.__init__  s     -6bcc+/;7"% &  
 !0-6_`der`s_tu  ,,4\]abn]o\pq  *rI   c                    | j                   S )zdRead only access to the :class:`~bson.codec_options.CodecOptions`
        of this instance.
        )r  r  s    rG   r  zBaseObject.codec_options  s    
 """rI   c                    | j                   S )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    rG   r  zBaseObject.write_concern  s     """rI   c                B    |r|j                   rt        S | j                  S )zBRead only access to the write concern of this instance or session.)in_transactionr#   r  r  sessions     rG   _write_concern_forzBaseObject._write_concern_for  s!     w--((!!!rI   c                    | j                   S )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    rG   rE  zBaseObject.read_preference  s     $$$rI   c                Z    |r|j                         xs | j                  S | j                  S )zDRead only access to the read preference of this instance or session.)_txn_read_preferencer  r  s     rG   _read_preference_forzBaseObject._read_preference_for  s-     //1JT5J5JJ$$$rI   c                    | j                   S )zRead only access to the :class:`~pymongo.read_concern.ReadConcern`
        of this instance.

        .. versionadded:: 3.2
        )r  r  s    rG   r  zBaseObject.read_concern  s     !!!rI   N)
r  r   rE  r!   r  r$   r  r   rq  None)rq  r   )rq  r$   )r   Optional[_AgnosticClientSession]rq  r$   )rq  r!   )r  r  rq  r!   )rq  r   )__name__
__module____qualname____doc__r  propertyr  r  r  rE  r  r  r`  rI   rG   r  r    s    *#* %* $	*
 "* 
*> # # # #" % %% " "rI   r  c                      e Zd ZddZddZddZddZddZddZddZ	ddZ
dd	ZdddZddZd dZd!dZedd"d       Zed#d       Zdd$dZd%dZddZy
)&rr  c                T    i | _         i | _        | j                  t        |i |       y r_  )%_CaseInsensitiveDictionary__casedkeys _CaseInsensitiveDictionary__datar   r   )r  argskwargss      rG   r  z#_CaseInsensitiveDictionary.__init__  s'    +-&(D$)&)*rI   c                :    |j                         | j                  v S r_  )rK   r  r  rR   s     rG   __contains__z'_CaseInsensitiveDictionary.__contains__  s    yy{dkk))rI   c                ,    t        | j                        S r_  )r   r  r  s    rG   __len__z"_CaseInsensitiveDictionary.__len__  s    4;;rI   c                (    d | j                   D        S )Nc              3      K   | ]  }|  y wr_  r`  )rl  rR   s     rG   ro  z6_CaseInsensitiveDictionary.__iter__.<locals>.<genexpr>  s     00s   )r  r  s    rG   __iter__z#_CaseInsensitiveDictionary.__iter__  s    0t//00rI   c                t    t        | D ci c]  }| j                  |   | j                  |   ! c}      S c c}w r_  )r`   r  r  )r  ks     rG   __repr__z#_CaseInsensitiveDictionary.__repr__  s3    FAD$$Q'Q7FGGFs   $5c                `    |j                         }|| j                  |<   || j                  |<   y r_  rK   r  r  )r  rR   rd   lc_keys       rG   __setitem__z&_CaseInsensitiveDictionary.__setitem__  s+    #& #FrI   c                <    | j                   |j                            S r_  )r  rK   r  s     rG   __getitem__z&_CaseInsensitiveDictionary.__getitem__  s    {{399;''rI   c                X    |j                         }| j                  |= | j                  |= y r_  r  )r  rR   r  s      rG   __delitem__z&_CaseInsensitiveDictionary.__delitem__  s'    V$KKrI   c                    t        |t        j                        st        S t	        |       t	        |      k7  ry|D ]  }| |   ||   k7  s y y)NFT)r_   r   r   NotImplementedr   r  otherrR   s      rG   __eq__z!_CaseInsensitiveDictionary.__eq__  sP    %-!!t9E
" 	CCyE#J&	 rI   Nc                V    | j                   j                  |j                         |      S r_  )r  r~  rK   r  rR   defaults      rG   r~  z_CaseInsensitiveDictionary.get  s    {{syy{G44rI   c                    |j                         }| j                  j                  |d         | j                  j                  |g|i |S r_  )rK   r  popr  )r  rR   r  r  r  s        rG   r  z_CaseInsensitiveDictionary.pop  sB    VT*t{{v7777rI   c                z    | j                   j                         \  }}| j                  j                  |      }||fS r_  )r  popitemr  r  )r  r  rf  rd   s       rG   r  z"_CaseInsensitiveDictionary.popitem  s8     ,,446	'%rI   c                l    | j                   j                          | j                  j                          y r_  )r  clearr  r  s    rG   r  z _CaseInsensitiveDictionary.clear  s$     rI   c                     y r_  r`  r  s      rG   
setdefaultz%_CaseInsensitiveDictionary.setdefault"      rI   c                     y r_  r`  r  s      rG   r  z%_CaseInsensitiveDictionary.setdefault&  r  rI   c                    |j                         }|| v r| j                  |   S || j                  |<   || j                  |<   |S r_  )rK   r  r  )r  rR   r  r  s       rG   r  z%_CaseInsensitiveDictionary.setdefault*  sF    $;;;v&&'*DV$")DKKNrI   c                    t        |t              r|D ]  }||   | |j                  |      <    y |D ]
  }||   | |<    y r_  )r_   rr  rf  r  s      rG   r   z!_CaseInsensitiveDictionary.update3  sQ    e78 8-23ZU__S)*8  '!#JS	'rI   c                <    | j                   |j                            S r_  )r  rK   r  s     rG   rf  z$_CaseInsensitiveDictionary.cased_key;  s    		,,rI   )r  r   r  r   )rR   r`   rq  r   )rq  rA   )rq  zIterator[str])rq  r`   )rR   r`   rd   r   rq  r  )rR   r`   rq  r   )rR   r`   rq  r  )r  r   rq  r   r_  )rR   r`   r  Optional[Any]rq  r   )rR   r`   r  r   r  r   rq  r   )rq  tuple[str, Any])rq  r  )rR   r`   r  r  rq  r  )rR   r`   r  r   rq  r   )rR   r`   r  r  rq  r  )r  Mapping[str, Any]rq  r  )r  r  r  r  r  r  r  r  r  r  r  r  r~  r  r  r  r   r  r   rf  r`  rI   rG   rr  rr    s{    +
* 1H$
( 
	58
 
    '-rI   rr  c                 0    	 ddl m}  y# t        $ r Y yw xY w)zIs the C extension installed?r   	_cmessageTF)pymongor  ImportErrorr  s    rG   has_cr  ?  s    % s   	 	)rC   r`   rq  ztuple[str, int]r_  )rR   r`   rS   Optional[list]rq  r   )rc   r`   rd   r   rq  r   )rc   r`   rd   r   rq  rA   )rc   r`   rd   r   rq  Optional[str])rc   r`   rd   r   rq  r0   )rc   r`   rd   r   rq  r`   )rc   r`   rd   r   rq  Union[int, str])rc   r   rd   r   rq  r  )rc   r`   rd   r   rq  r   )rc   r`   rd   r   rq  Optional[float])rc   r   rd   r   rq  r  )r   r   rd   r   rq  r!   )r   r   rd   r   rq  rA   )r   r`   rd   r   rq  zlist[dict[str, str]])rc   r`   rd   r   rq  zdict[str, Union[bool, str]])rc   r`   rd   r   rq  z2Union[Type[MutableMapping], Type[RawBSONDocument]])rc   r   rd   r   rq  zOptional[TypeRegistry])rc   r`   rd   r   rq  r   )rc   r   rd   r   rq  r  )rc   r   rd   r   rq  r  )rc   r`   rd   r   rq  r  )rc   r   rd   r   rq  zOptional[DriverInfo])rc   r   rd   r   rq  zOptional[ServerApi])rc   r   rd   r   rq  zOptional[Callable])r   r  rq  r  )r   r   rq  r  )r   r   rd   r`   rq  r`   )r   r   rd   r   rq  zOptional[datetime.tzinfo])rc   r   rd   r   rq  r  )rc   r   rd   r   rq  zOptional[DatetimeConversion])rc   r`   rd   r`   rq  r`   )rc   r`   rd   r   rq  r  )rR   r`   rW  r4  rX  r  rq  r	   )T)rg  r  rv  r   rq  zMutableMapping[str, Any])r  r  r   r`   rq  r   )rq  r   )r  
__future__r   r   ru  collectionsr   r   difflibr   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_CONNECTINGr1   r2   r3   LOCAL_THRESHOLD_MSRETRY_WRITESRETRY_READSr6   r8   _MAX_END_SESSIONSSRV_SERVICE_NAMESERVER_MONITORING_MODErt  rH   rL   rU   UNSPECIFIEDSTANDARDPYTHON_LEGACYJAVA_LEGACYCSHARP_LEGACYr   re   rk   rp   rr   rw   rz   r|   rt   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  r5  rB  rL  rM  rN  r   r   optnamealiasesaliascopyrO  rP  rS  rT  rY  rR  ry  r  r  WRITE_CONCERN_OPTIONSr  r`   rr  r  r`  rI   rG   <module>r     s    @ "   ( %    &  * M M ) + - 8 , ? ( W W6 "%k 2~ 2 #      %                    #' - & $( = ' %) M (     */  . %7 M 6        22 	" &11"++&44$00&44 +	]48e*&2;
;;C4		* 
 4n7*(


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 RGW R11/H/Q%e,RR 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rI   