o
    C©Ì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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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d€d�„Z{�ddƒd„„Z|�dd†d‡„Z}�dd‰dŠ„Z~�ddŒd�„Z�dd�d�„Z€�dd‘d’„Z��dd“d”„Z‚�d	d•d–„Zƒ�dd˜d™„Z„�dd›dœ„Z…�ddždŸ„Z†�dd¢d£„Z‡�dd¥d¦„Zˆeyg d§¢ƒZ‰�d d¨d©„ZŠ�d!d«d¬„Z‹�d"d®d¯„ZŒ�d#d±d²„Z��d$d³d´„ZŽdµd¶giZ�d·e:d¸< i d¹eƒ“dºev“d»e{“d¼ei“d½e$“d¾eq“d¿eb“dÀeo“dÁeb“dÂen“dÃeo“dÄed“dÅeh“dÆes“dÇej“dÈeu“dÉex“i dÊej“dËeb“dÌeb“dÍeb“dÎep“dÏeq“dµeb“dÐeb“dÑeb“dÒef“dÓef“dÔej“dÕeb“dÖeb“d×el“dØee“dÙe%“¥eieeereŽdÚœ¥Z�dÛe:dÜ< ebe„e…ebeeefebeŠeweheoe�dÝœZ‘dÛe:dÞ< e|e}ete+e‹ejeje†eŒe~dßœ
Z’dÛe:dà< d¶dµiZ“dáe:dâ< i Z”dãe:dä< e� •e‘¡ e� –¡ D ]\Z—Z˜e˜D ]Z™e™e�v�rëe�e— e�e™< �qÞ�qØe� š¡ Z›dÛe:då< e› •e’¡ g dæ¢Zœdçe:dè< eyd»gƒZ��d%dêdë„Zž	�d�d&dïdð„ZŸ�d%dñdò„Z 	*�d'�d(död÷„Z¡�d)dùdú„Z¢�d)dûdü„Z£eyg dý¢ƒZ¤G dþdÿ„ dÿƒZ¥G �d �d„ �dee¦ef ƒZ§�d*�d�d„Z¨d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[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_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.i‰i  ú:éÿÿÿÿNr*   ú[)ÚrfindÚintÚ
startswith)r;   ÚhostÚportÚidx© rH   ú]/var/www/html/Moveonwheels/move_on_wheels/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[str]]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    eÍÍAz1 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 )zâValidates 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 )z¿Validates 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 )z®Validate 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
¡\}}}|sŒtdƒ‚|tvr£d|v r˜tdƒ‚t|› dttƒ› �ƒ‚|dkr´d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»   ú<Union[Type[MutableMapping[str, Any]], 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Ã   ú	list[Any]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Å   úOptional[list[Any]]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[..., Any]]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   rA  Ú
validatorsÚ
normed_keyúCallable[[Any, Any], Any]c                 C  s@   |p| }z|| W S  t y   t||dd�}t| |ƒ Y d S w )Ngš™™™™™É?)Úcutoff)r˜   r   rU   )rM   rB  rC  rN   rH   rH   rI   Ú_get_validator>  s   
þrF  c                 C  s$   t | t|  ¡ d�}|| |ƒ}| |fS )zGeneric validation function.©rC  )rF  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   ©rL  rH   rH   rI   Úget_normed_key_  ó   z-get_validated_options.<locals>.get_normed_keyc                   s
   ˆ   | ¡S rN  )Ú	cased_keyrO  )rI  rH   rI   Úget_setter_keyb  ó   
z-get_validated_options.<locals>.get_setter_keyc                 S  s   |   ¡ S rN  )rK   rO  rH   rH   rI   rP  h  s   c                 S  rM  rN  rH   rO  rH   rH   rI   rS  k  rQ  rG  rþ   c                 3  s   � | ]	}|t ˆ ƒv V  qd S rN  ©r<   )Ú.0Úp)ÚexcrH   rI   Ú	<genexpr>v  s   € z(get_validated_options.<locals>.<genexpr>z*is not a supported auth mechanism propertyr.   )Ú
stacklevelN)rL  r<   r=   r<   )ra   Ú_CaseInsensitiveDictionaryr´   rF  r"  rb   rg   r   ÚanyÚ_MECH_PROP_MUST_RAISEr<   ÚwarningsrJ  )
rI  rJ  Úvalidated_optionsrP  rS  r¹   r\   rC  rH  Ú	validatedrH   )rX  rI  rI   Úget_validated_optionsP  s4   



ÿþ€øra  Úencrypted_fieldsc                 C  ó   |   dd|› d�¡S )NÚescCollectionúenxcol_.z.esc©Úget©rb  rš   rH   rH   rI   Ú_esc_coll_nameƒ  ó   ri  c                 C  rc  )NÚecocCollectionre  z.ecocrf  rh  rH   rH   rI   Ú_ecoc_coll_name‡  rj  rl  )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 )$Ú
BaseObjectz™A base class that provides attributes and methods common
    to multiple pymongo classes.

    SHOULD NOT BE USED BY DEVELOPERS EXTERNAL TO MONGODB.
    Úcodec_optionsúCodecOptions[Any]r2  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)Úselfrp  r2  rr  rs  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.
        )rt  ©rx  rH   rH   rI   rp  µ  s   zBaseObject.codec_optionsc                 C  rz  )zÈRead only access to the :class:`~pymongo.write_concern.WriteConcern`
        of this instance.

        .. versionchanged:: 3.0
          The :attr:`write_concern` attribute is now read only.
        )rv  r{  rH   rH   rI   rr  ¼  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"   rr  ©rx  r|  rH   rH   rI   Ú_write_concern_forÆ  s   
zBaseObject._write_concern_forc                 C  rz  )z¥Read only access to the read preference of this instance.

        .. versionchanged:: 3.0
          The :attr:`read_preference` attribute is now read only.
        )ru  r{  rH   rH   rI   r2  Í  ó   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_preferenceru  r  rH   rH   rI   Ú_read_preference_forÖ  s   zBaseObject._read_preference_forc                 C  rz  )z„Read only access to the :class:`~pymongo.read_concern.ReadConcern`
        of this instance.

        .. versionadded:: 3.2
        )rw  r{  rH   rH   rI   rs  Ý  r�  zBaseObject.read_concernN)
rp  rq  r2  r    rr  r#   rs  r   r=   rÈ   )r=   rq  )r=   r#   )r|  r}  r=   r#   )r=   r    )r|  r}  r=   r    )r=   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ry  Úpropertyrp  rr  r€  r2  rƒ  rs  rH   rH   rH   rI   ro  �  s    

	
ro  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 )Fr[  Úargsr   Úkwargsc                 O  s$   i | _ i | _|  t|i |¤Ž¡ d S rN  )Ú%_CaseInsensitiveDictionary__casedkeysÚ _CaseInsensitiveDictionary__datará   r³   )rx  r‰  rŠ  rH   rH   rI   ry  è  s   z#_CaseInsensitiveDictionary.__init__rM   r<   r=   r]   c                 C  s   |  ¡ | jv S rN  )rK   rŒ  ©rx  rM   rH   rH   rI   Ú__contains__í  ó   z'_CaseInsensitiveDictionary.__contains__rC   c                 C  s
   t | jƒS rN  )rÏ   rŒ  r{  rH   rH   rI   Ú__len__ð  rT  z"_CaseInsensitiveDictionary.__len__úIterator[str]c                 C  s   dd„ | j D ƒS )Nc                 s  s   � | ]}|V  qd S rN  rH   )rV  rM   rH   rH   rI   rY  ô  s   € z6_CaseInsensitiveDictionary.__iter__.<locals>.<genexpr>)r‹  r{  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Œ  )rV  Úkr{  rH   rI   Ú
<dictcomp>÷  s    z7_CaseInsensitiveDictionary.__repr__.<locals>.<dictcomp>rU  r{  rH   r{  rI   Ú__repr__ö  s   z#_CaseInsensitiveDictionary.__repr__r\   rÈ   c                 C  s    |  ¡ }|| j|< || j|< d S rN  ©rK   r‹  rŒ  )rx  rM   r\   Úlc_keyrH   rH   rI   Ú__setitem__ù  s   
z&_CaseInsensitiveDictionary.__setitem__c                 C  ó   | j | ¡  S rN  )rŒ  rK   r�  rH   rH   rI   Ú__getitem__þ  r�  z&_CaseInsensitiveDictionary.__getitem__c                 C  s   |  ¡ }| j|= | j|= d S rN  r–  )rx  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Ï   ©rx  rœ  rM   rH   rH   rI   Ú__eq__  s   ÿz!_CaseInsensitiveDictionary.__eq__NÚdefaultrí   c                 C  s   | j  | ¡ |¡S rN  )rŒ  rg  rK   ©rx  rM   r   rH   rH   rI   rg    s   z_CaseInsensitiveDictionary.getc                 O  s0   |  ¡ }| j |d ¡ | jj|g|¢R i |¤ŽS rN  )rK   r‹  ÚpoprŒ  )rx  rM   r‰  rŠ  r—  rH   rH   rI   r¢    s   z_CaseInsensitiveDictionary.popr>  c                 C  s"   | j  ¡ \}}| j |¡}||fS rN  )r‹  ÚpopitemrŒ  r¢  )rx  r—  rR  r\   rH   rH   rI   r£    s   z"_CaseInsensitiveDictionary.popitemc                 C  s   | j  ¡  | j ¡  d S rN  )r‹  ÚclearrŒ  r{  rH   rH   rI   r¤    s   
z _CaseInsensitiveDictionary.clearc                 C  ó   d S rN  rH   r¡  rH   rH   rI   Ú
setdefault"  ó   z%_CaseInsensitiveDictionary.setdefaultc                 C  r¥  rN  rH   r¡  rH   rH   rI   r¦  &  r§  c                 C  s2   |  ¡ }|| v r| j| S || j|< || j|< |S rN  )rK   rŒ  r‹  )rx  rM   r   r—  rH   rH   rI   r¦  *  s   


rÛ   c                 C  sD   t |tƒr|D ]}|| | | |¡< qd S |D ]}|| | |< qd S rN  )ra   r[  rR  rž  rH   rH   rI   rá   3  s   
ÿÿz!_CaseInsensitiveDictionary.updatec                 C  r™  rN  )r‹  rK   r�  rH   rH   rI   rR  ;  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]   rN  )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†  ry  rŽ  r�  r’  r•  r˜  rš  r›  rŸ  rg  r¢  r£  r¤  r   r¦  rá   rR  rH   rH   rH   rI   r[  ç  s*    












	r[  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>   rN  )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=   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=   r>  )rM   r<   rB  r!  rC  rp   r=   rD  )T)rI  rÛ   rJ  r]   r=   rK  )rb  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_MODEr]  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/  r9  r:  r;  rá   r´   ÚoptnameÚaliasesÚaliasÚcopyr<  r=  r@  rA  rF  r?  ra  ri  rl  ÚWRITE_CONCERN_OPTIONSro  r<   r[  r¬  rH   rH   rH   rI   Ú<module>   sÔ  8
û				
		ÿ7

			
ÿÿþýüûúùø	÷
öõôóòñðïîíìëêéèçæåäãâá à!ß"Þ#Ú,ôöÿ

€þ


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