o
    'h                     @  s  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rd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ZXdd8d9ZYdd:d;ZZddd@dAZ[ej\ej]ej^ej_ej`dBZaddGdHZbddJdKZcddLdMZdddNdOZeddQdRZfd	dSdTZgd	dUdVZhd
dWdXZiddYdZZjdd\d]Zkdd^d_ZlddadbZmddcddZnddfdgZoddhdiZpddjdkZqddldmZrddndoZsddrdsZtddtduZud
dvdwZvddxdyZwdd|d}Zxeyg d~ZzdddZ{dddZ|dddZ}dddZ~dddZdddZdddZdddZdddZdddZdddZdddZdddZdddZeyg dZdddZd ddZd!ddZd"ddZd#ddZddgiZde:d< i dedevde{deide$deqdebdeodebdendeodeddehdesdejdeudexi dejdebdebdebdepdeqdebdebdebdefdefdejdebdebdeldeede%eieeeredٜZde:d< ebeeebeeefebeeweheoedܜZde:d< e|e}ete+eejejeee~dޜ
Zde:d< ddiZde:d< i Zde:d< ee e D ]\ZZeD ]Zeevree ee< qސqe Zde:d< ee g dZde:d< eydgZd$ddZ	dd%ddZd$ddZ	*d&d'ddZd(ddZd(ddZeyg dZG dd dZG dd  d eeef Zd)ddZdS (*  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_NAMEnodestrreturntuple[str, int]c                 C  sZ   | }d}|  d}|dkr| d| t| |d d }}|dr)|dd }||fS )z5Split a host:port string into (host, int(port)) pair.ii  :Nr*   [)rfindint
startswith)r;   hostportidx rH   J/var/www/html/olx_land/venv/lib/python3.10/site-packages/pymongo/common.pypartition_node   s   
"
rJ   c                 C  s   t | \}}| |fS )z6Split and normalize a node name from a hello response.)rJ   lower)r;   rE   rF   rH   rH   rI   
clean_node   s   rL   keysuggestionsOptional[list]r   c                 C  s.   d|  d}|r|dd | d7 }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   )rM   rN   msgrH   rH   rI   raise_config_error   s   rU   )unspecifiedstandardpythonLegacy
javaLegacycsharpLegacyoptionvaluer   boolc                 C  s4   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^   )
isinstancer<   
ValueErrorr$   r[   r\   rH   rH   rI   validate_boolean_or_string   s
   

rd   rC   c                 C  s\   t |tr|S t |tr"zt|W S  ty!   td|  ddw td|  dt| )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   r<   rb   	TypeErrortyperc   rH   rH   rI   validate_integer   s   


ri   c                 C  s&   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ri   rb   r[   r\   valrH   rH   rI   validate_positive_integer      
rm   c                 C  s&   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 integerrj   rk   rH   rH   rI   validate_non_negative_integer   rn   ro   Optional[str]c                 C  s&   |du r|S t | |}t|  |S )z1Validates that 'value' is file-like and readable.N)validate_stringopencloserc   rH   rH   rI   validate_readable   s
   
rt   c                 C     |du r|S t | |S )z4Validate that 'value' is a positive integer or None.Nrm   rc   rH   rH   rI   !validate_positive_integer_or_none      
rw   c                 C  ru   )z9Validate that 'value' is a positive integer or 0 or None.N)ro   rc   rH   rH   rI   %validate_non_negative_integer_or_none   rx   ry   c                 C  s&   t |tr|S td|  dt| )z/Validates that 'value' is an instance of `str`.re   z(, value must be an instance of str, not )ra   r<   rg   rh   rc   rH   rH   rI   rq      s   
rq   c                 C  ru   )z@Validates that 'value' is an instance of `basestring` or `None`.N)rq   rc   rH   rH   rI   validate_string_or_none   rx   rz   Union[int, str]c                 C  sR   t |tr|S t |trzt|W S  ty   | Y S w td|  dt| )/Validates that 'value' is an integer or string.re   z,, value must be an integer or a string, not rf   rc   rH   rH   rI   validate_int_or_basestring  s   


r}   c                 C  s^   t |tr|S t |tr#zt|}W n ty   | Y S w t| |S td|  dt| )r|   re   z9, value must be an non negative integer or a string, not )ra   rC   r<   rb   ro   rg   rh   rk   rH   rH   rI   'validate_non_negative_int_or_basestring  s   


r~   floatc                 C  sn   |  d}zt |}W n ty   t|d ty"   t|dw d|  k r-dk s5n t|  d|S )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)r   rb   rg   )r[   r\   errmsgrH   rH   rI   validate_positive_float$  s   


r   c                 C     |dks|dkr
dS t | |S )zgValidates that 'value' is 0 or a positive float, or can be converted to
    0 or a positive float.
    r   0r   rc   rH   rH   rI   validate_positive_float_or_zero7  s   
r   Optional[float]c                 C  s   |du r|S t | |d S zcValidates a timeout specified in milliseconds returning
    a value in floating point seconds.
    N     @@r   rc   rH   rH   rI   validate_timeout_or_none@     r   c                 C  s8   |du rt |  d|dks|dkrdS t| |d 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.
    Nz cannot be Noner   r   r   )r   r   rc   rH   rH   rI   validate_timeout_or_zeroI  s
   r   c                 C  s*   |du s|dks|dkrdS t | |d 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   rc   rH   rH   rI    validate_timeout_or_none_or_zeroV  s   r   c                 C  s   |du rdS t | |d S r   )r   rc   rH   rH   rI   validate_timeoutms`  r   r   c                 C  r   )zBValidates maxStalenessSeconds according to the Max Staleness Spec.r@   z-1rv   rc   rH   rH   rI   validate_max_stalenessi  s   
r   dummyr    c                 C  s   t |tst|d|S )zValidate a read preference.z is not a read preference)ra   r    rg   r   r\   rH   rH   rI   validate_read_preferenceq  s   
r   c                 C  s   |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   rb   r   rH   rH   rI   validate_read_preference_modex  s   r   c                 C  s.   ddl m} ||vrt|  dt| |S )z&Validate the authMechanism URI option.r   )
MECHANISMSz must be in )pymongo.auth_sharedr   rb   tuple)r[   r\   r   rH   rH   rI   validate_auth_mechanism  s   r   c                 C  s2   zt | W S  ty   t| dtt  dw )z<Validate the uuid representation option selected in the URI.z3 is an invalid UUID representation. Must be one of N)_UUID_REPRESENTATIONSKeyErrorrb   r   r   rH   rH   rI   validate_uuid_representation  s   
r   namelist[dict[str, str]]c              	   C  s   t |ts|g}g }|D ]=}|dkr|i  qz i }|dD ]}|d\}}t||t|< q || W q tyI   t|d|  dw |S )z5Parse readPreferenceTags if passed as a client kwarg. ,r?   z not a valid value for N)ra   listappendsplitr   	Exceptionrb   )r   r\   tag_setstag_settagstagrM   rl   rH   rH   rI   validate_read_preference_tags  s"   

r   )SERVICE_NAMESERVICE_HOSTr:   SERVICE_REALMAWS_SESSION_TOKENENVIRONMENTTOKEN_RESOURCEdict[str, Union[bool, str]]c           	      C  sv  i }t |tsnt |tstdt| | D ]R\}}t |tr'|||< qt |tr5t| ||< q|dv rCt |trC|||< q|dv r`ddl	m
} t ||s[tdt| |||< qtd| dt| |S t| |}t|}|d	D ]<}|d
\}}}|std|tvrd|v rtdt| dtt |dkrddlm} ||||< q||||< q||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 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   r<   dictrb   rh   itemsr]   rK   r   pymongo.auth_oidc_sharedr   rq   r   r   	partition_MECHANISM_PROPSr   r   r   )	r[   r\   propsrM   r   opt_rl   r   rH   rH   rI   "validate_auth_mechanism_properties  sR   









r   2Union[Type[MutableMapping], Type[RawBSONDocument]]c                 C  s`   d}zt |tj}W n ty   t|drt |jtj}Y nw |s.t |ts.t|  d|S )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   rg   hasattrr   r   )r[   r\   
is_mappingrH   rH   rI   validate_document_class  s   
r   Optional[TypeRegistry]c                 C  s(   |durt |tst|  dt |S )z"Validate the type_registry option.Nz must be an instance of )ra   r   rg   rc   rH   rH   rI   validate_type_registry  s   r   r   c                 C  s$   t |tst|  dt| |S )z!Validates that 'value' is a list.z must be a list, not )ra   r   rg   rh   rc   rH   rH   rI   validate_list  s   
r   c                 C  ru   )z)Validates that 'value' is a list or None.N)r   rc   rH   rH   rI   validate_list_or_none  rx   r   Nonec                 C  "   t |tjtfst|  ddS )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   rg   rc   rH   rH   rI   validate_list_or_mapping  
   r   c                 C  s   t |tjst|  ddS )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
   rg   rc   rH   rH   rI   validate_is_mapping&  s
   r   c                 C  r   )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   rg   rc   rH   rH   rI   validate_is_document_type0  r   r   c                 C  s:   |du r|S t | | t|ddkrt|  d|S )zValidate the appname option.Nzutf-8   z must be <= 128 bytes)rq   lenencoderb   rc   rH   rH   rI   validate_appname_or_none;  s   
r   Optional[DriverInfo]c                 C  s(   |du r|S t |tst|  d|S ) Validate the driver keyword arg.Nz" must be an instance of DriverInfo)ra   r   rg   rc   rH   rH   rI   validate_driver_or_noneF  s
   
r   Optional[ServerApi]c                 C  s0   |du r|S t |tst|  dt| |S )z$Validate the server_api keyword arg.Nz' must be an instance of ServerApi, not )ra   r!   rg   rh   rc   rH   rH   rI   validate_server_api_or_noneO  s
   
r   Optional[Callable]c                 C  s.   |du r|S t |st|  dt| |S )z%Validates that 'value' is a callable.Nz must be a callable, not )callablerb   rh   rc   rH   rH   rI   validate_is_callable_or_noneX  s
   r   replacementMapping[str, Any]c                 C  sB   t d|  | rt| tstt| }|drtddS dS dS )z Validate a replacement document.r   $z'replacement can not include $ operatorsN)r   ra   r   nextiterrD   rb   )r   firstrH   rH   rI   validate_ok_for_replacea  s   

r   updatec                 C  sL   t d|  | stdt| t }tt| }|r"|ds$tddS dS )zValidate an update document.r   zupdate cannot be emptyr   z"update only works with $ operatorsN)r   rb   ra   r   r   r   rD   )r   is_documentr   rH   rH   rI   validate_ok_for_updatek  s   
r   )strictreplaceignorec                 C  s"   |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_HANDLERSrb   r   r   rH   rH   rI   %validate_unicode_decode_error_handler{  s   r   Optional[datetime.tzinfo]c                 C  s$   |durt |tjstd| |S )zValidate the tzinfo optionNz)%s must be an instance of datetime.tzinfo)ra   datetimetzinforg   r   rH   rH   rI   validate_tzinfo  s   r   Optional[Any]c                 C  s<   |du r|S ddl m} t||st|  dt| |S )r   Nr   )AutoEncryptionOptsz0 must be an instance of AutoEncryptionOpts, not )pymongo.encryption_optionsr   ra   rg   rh   )r[   r\   r   rH   rH   rI   %validate_auto_encryption_opts_or_none  s   
r   Optional[DatetimeConversion]c                 C  s\   |du rt jS t|tr| rt t|S t | S t|tr#t |S t|  dt| )z%Validate a DatetimeConversion string.Nz; must be a str or int representing DatetimeConversion, not )r   DATETIMEra   r<   isdigitrC   rg   rh   rc   rH   rH   rI   validate_datetime_conversion  s   

r   c                 C  s    |dvrt |  d|d|S )z)Validate the serverMonitoringMode option.>   r9   pollstream=z7 is invalid. Must be one of "auto", "stream", or "poll")rb   rc   rH   rH   rI   validate_server_monitoring_mode  s
   r   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_OPTIONStuple[str, Any]c                 C  s2   t | |\}}|tvrtd|  dt | |fS )z,Validate optional authentication parameters.rP   z. Must be in )validate_AUTH_OPTIONSr   )r[   r\   rK   rH   rH   rI   validate_auth_option6  s   r?  
validators
normed_keyr   c                 C  s@   |p| }z|| W S  t y   t||dd}t| | Y d S w )Ng?)cutoff)r   r   rU   )rM   r@  rA  rN   rH   rH   rI   _get_validator>  s   
rC  c                 C  s$   t | t|  d}|| |}| |fS )zGeneric validation function.rA  )rC  r:  rK   )r[   r\   	validatorrH   rH   rI   r=  I  s   
r=  optionswarnMutableMapping[str, Any]c           
        s   t trt }ddd}dfdd}ni }ddd}dd	d} D ]U\}}||}zt|t|d
}|||}	W n8 tttfys   z)|dkr\t fddt	D r\dt
 vr\ |rhtjt
 dd n W Y d  q%d  ww |	|||< q%|S )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.
    xr<   r=   c                 S     | S NrH   rI  rH   rH   rI   get_normed_key_     z-get_validated_options.<locals>.get_normed_keyc                   s
     | S rK  )	cased_keyrL  )rF  rH   rI   get_setter_keyb     
z-get_validated_options.<locals>.get_setter_keyc                 S  s   |   S rK  )rK   rL  rH   rH   rI   rM  h  s   c                 S  rJ  rK  rH   rL  rH   rH   rI   rP  k  rN  rD  r   c                 3  s    | ]	}|t  v V  qd S rK  r<   ).0p)excrH   rI   	<genexpr>v  s    z(get_validated_options.<locals>.<genexpr>z*is not a supported auth mechanism propertyr.   )
stacklevelN)rI  r<   r=   r<   )ra   _CaseInsensitiveDictionaryr   rC  r   rb   rg   r   any_MECH_PROP_MUST_RAISEr<   warningsrG  )
rF  rG  validated_optionsrM  rP  r   r\   rA  rE  	validatedrH   )rU  rF  rI   get_validated_optionsP  s4   



r^  encrypted_fieldsc                 C     |  dd| dS )NescCollectionenxcol_.z.escgetr_  r   rH   rH   rI   _esc_coll_name     rf  c                 C  r`  )NecocCollectionrb  z.ecocrc  re  rH   rH   rI   _ecoc_coll_name  rg  ri  )r  wtimeoutr  r$  jr  c                   @  sf   e Zd ZdZdddZedddZedddZd ddZed!ddZ	d"ddZ
ed#ddZdS )$
BaseObjectzA base class that provides attributes and methods common
    to multiple pymongo classes.

    SHOULD NOT BE USED BY DEVELOPERS EXTERNAL TO MONGODB.
    codec_optionsr   r0  r    write_concernr#   read_concernr   r=   r   c                 C  s~   t |ts	td|| _t |tst|d|| _t |ts)tdt| || _t |t	s:tdt| || _
d S )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   rg   _codec_optionsr    _read_preferencer#   rh   _write_concernr   _read_concern)selfrm  r0  rn  ro  rH   rH   rI   __init__  s$   




zBaseObject.__init__c                 C     | j S )zdRead only access to the :class:`~bson.codec_options.CodecOptions`
        of this instance.
        )rp  rt  rH   rH   rI   rm    s   zBaseObject.codec_optionsc                 C  rv  )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.
        )rr  rw  rH   rH   rI   rn    s   zBaseObject.write_concernsession Optional[_AgnosticClientSession]c                 C  s   |r|j rtS | jS )zBRead only access to the write concern of this instance or session.)in_transactionr"   rn  rt  rx  rH   rH   rI   _write_concern_for  s   
zBaseObject._write_concern_forc                 C  rv  )zRead only access to the read preference of this instance.

        .. versionchanged:: 3.0
          The :attr:`read_preference` attribute is now read only.
        )rq  rw  rH   rH   rI   r0       zBaseObject.read_preferencec                 C  s   |r	|  p| jS | jS )zDRead only access to the read preference of this instance or session.)_txn_read_preferencerq  r{  rH   rH   rI   _read_preference_for  s   zBaseObject._read_preference_forc                 C  rv  )zRead only access to the :class:`~pymongo.read_concern.ReadConcern`
        of this instance.

        .. versionadded:: 3.2
        )rs  rw  rH   rH   rI   ro    r}  zBaseObject.read_concernN)
rm  r   r0  r    rn  r#   ro  r   r=   r   )r=   r   )r=   r#   )rx  ry  r=   r#   )r=   r    )rx  ry  r=   r    )r=   r   )__name__
__module____qualname____doc__ru  propertyrm  rn  r|  r0  r  ro  rH   rH   rH   rI   rl    s    

	
rl  c                   @  s   e Zd Zd4ddZd5d
dZd6ddZd7ddZd8ddZd9ddZd:ddZ	d;ddZ
d<ddZd=d>d"d#Zd?d$d%Zd@d'd(ZdAd)d*Zed=dBd+d,ZedCd-d,Zd=dDd.d,ZdEd0d1Zd:d2d3ZdS )FrX  argsr   kwargsc                 O  s$   i | _ i | _| t|i | d S rK  )%_CaseInsensitiveDictionary__casedkeys _CaseInsensitiveDictionary__datar   r   )rt  r  r  rH   rH   rI   ru    s   z#_CaseInsensitiveDictionary.__init__rM   r<   r=   r]   c                 C  s   |  | jv S rK  )rK   r  rt  rM   rH   rH   rI   __contains__     z'_CaseInsensitiveDictionary.__contains__rC   c                 C  s
   t | jS rK  )r   r  rw  rH   rH   rI   __len__  rQ  z"_CaseInsensitiveDictionary.__len__Iterator[str]c                 C  s   dd | j D S )Nc                 s  s    | ]}|V  qd S rK  rH   )rS  rM   rH   rH   rI   rV    s    z6_CaseInsensitiveDictionary.__iter__.<locals>.<genexpr>)r  rw  rH   rH   rI   __iter__  s   z#_CaseInsensitiveDictionary.__iter__c                   s   t  fdd D S )Nc                   s   i | ]} j |  j| qS rH   )r  r  )rS  krw  rH   rI   
<dictcomp>  s    z7_CaseInsensitiveDictionary.__repr__.<locals>.<dictcomp>rR  rw  rH   rw  rI   __repr__  s   z#_CaseInsensitiveDictionary.__repr__r\   r   c                 C  s    |  }|| j|< || j|< d S rK  rK   r  r  )rt  rM   r\   lc_keyrH   rH   rI   __setitem__  s   
z&_CaseInsensitiveDictionary.__setitem__c                 C     | j |  S rK  )r  rK   r  rH   rH   rI   __getitem__  r  z&_CaseInsensitiveDictionary.__getitem__c                 C  s   |  }| j|= | j|= d S rK  r  )rt  rM   r  rH   rH   rI   __delitem__  s   z&_CaseInsensitiveDictionary.__delitem__otherc                 C  sH   t |tjstS t| t|krdS |D ]}| | || kr! dS qdS )NFT)ra   r   r
   NotImplementedr   rt  r  rM   rH   rH   rI   __eq__  s   z!_CaseInsensitiveDictionary.__eq__Ndefaultr   c                 C  s   | j | |S rK  )r  rd  rK   rt  rM   r  rH   rH   rI   rd    s   z_CaseInsensitiveDictionary.getc                 O  s0   |  }| j|d  | jj|g|R i |S rK  )rK   r  popr  )rt  rM   r  r  r  rH   rH   rI   r    s   z_CaseInsensitiveDictionary.popr<  c                 C  s"   | j  \}}| j|}||fS rK  )r  popitemr  r  )rt  r  rO  r\   rH   rH   rI   r    s   z"_CaseInsensitiveDictionary.popitemc                 C  s   | j   | j  d S rK  )r  clearr  rw  rH   rH   rI   r    s   
z _CaseInsensitiveDictionary.clearc                 C     d S rK  rH   r  rH   rH   rI   
setdefault"     z%_CaseInsensitiveDictionary.setdefaultc                 C  r  rK  rH   r  rH   rH   rI   r  &  r  c                 C  s2   |  }|| v r| j| S || j|< || j|< |S rK  )rK   r  r  )rt  rM   r  r  rH   rH   rI   r  *  s   


r   c                 C  sD   t |tr|D ]}|| | ||< qd S |D ]}|| | |< qd S rK  )ra   rX  rO  r  rH   rH   rI   r   3  s   
z!_CaseInsensitiveDictionary.updatec                 C  r  rK  )r  rK   r  rH   rH   rI   rO  ;  r  z$_CaseInsensitiveDictionary.cased_key)r  r   r  r   )rM   r<   r=   r]   )r=   rC   )r=   r  )r=   r<   )rM   r<   r\   r   r=   r   )rM   r<   r=   r   )rM   r<   r=   r   )r  r   r=   r]   rK  )rM   r<   r  r   r=   r   )rM   r<   r  r   r  r   r=   r   )r=   r<  )r=   r   )rM   r<   r  r   r=   r   )rM   r<   r  r   r=   r   )rM   r<   r  r   r=   r   )r  r   r=   r   )r  r  r  ru  r  r  r  r  r  r  r  r  rd  r  r  r  r   r  r   rO  rH   rH   rH   rI   rX    s*    












	rX  c                  C  s(   z	ddl m}  W dS  ty   Y dS w )zIs the C extension installed?r   	_cmessageTF)pymongor  ImportErrorr  rH   rH   rI   has_c?  s   r  )r;   r<   r=   r>   rK  )rM   r<   rN   rO   r=   r   )r[   r<   r\   r   r=   r]   )r[   r<   r\   r   r=   rC   )r[   r<   r\   r   r=   rp   )r[   r<   r\   r   r=   r/   )r[   r<   r\   r   r=   r<   )r[   r<   r\   r   r=   r{   )r[   r   r\   r   r=   r{   )r[   r<   r\   r   r=   r   )r[   r<   r\   r   r=   r   )r[   r   r\   r   r=   r   )r   r   r\   r   r=   r    )r   r   r\   r   r=   rC   )r   r<   r\   r   r=   r   )r[   r<   r\   r   r=   r   )r[   r<   r\   r   r=   r   )r[   r   r\   r   r=   r   )r[   r<   r\   r   r=   r   )r[   r   r\   r   r=   rO   )r[   r   r\   r   r=   r   )r[   r<   r\   r   r=   r   )r[   r   r\   r   r=   r   )r[   r   r\   r   r=   r   )r[   r   r\   r   r=   r   )r   r   r=   r   )r   r   r=   r   )r   r   r\   r<   r=   r<   )r   r   r\   r   r=   r   )r[   r   r\   r   r=   r   )r[   r   r\   r   r=   r   )r[   r<   r\   r<   r=   r<   )r[   r<   r\   r   r=   r<  )rM   r<   r@  r  rA  rp   r=   r   )T)rF  r   rG  r]   r=   rH  )r_  r   r   r<   r=   r   )r=   r]   )r  
__future__r   r   r[  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_CONNECTINGr0   r1   r2   LOCAL_THRESHOLD_MSRETRY_WRITESRETRY_READSr5   r7   _MAX_END_SESSIONSSRV_SERVICE_NAMESERVER_MONITORING_MODErZ  rJ   rL   rU   UNSPECIFIEDSTANDARDPYTHON_LEGACYJAVA_LEGACYCSHARP_LEGACYr   rd   ri   rm   ro   rt   rw   ry   rq   rz   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   r   r-  r7  r8  r9  r   r   optnamealiasesaliascopyr:  r;  r>  r?  rC  r=  r^  rf  ri  WRITE_CONCERN_OPTIONSrl  r<   rX  r  rH   rH   rH   rI   <module>   s  8
				
		7

			
	
 !"#,




	3XX