
    FCf0                    x   d Z ddlmZ ddl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mZ ddl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mZmZ ddl m!Z! ddl"m#Z# ddl$m%Z%m&Z& erddl
m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z- 	 	 	 	 	 	 	 	 	 	 ddZ.ddZ/ddZ0d dZ1d!dZ2	 	 	 	 	 	 	 	 	 	 d"dZ3 G d d      Z4y)#z$Tools to parse mongo client options.    )annotations)TYPE_CHECKINGAnyMappingOptionalSequencecast)_parse_codec_options)common)MongoCredential_build_credentials_tuple)CompressionSettings)ConfigurationError)_EventListener_EventListeners)PoolOptions)ReadConcern)_ServerModemake_read_preferenceread_pref_mode_from_name)any_server_selector)get_ssl_context)WriteConcernvalidate_boolean)CodecOptions)AutoEncryptionOpts)
SSLContext)_ServerSelectorc                z    |j                  d| rdnd      }|j                  d      }| s|rt        ||| |||      S y)z!Parse authentication credentials.authmechanismDEFAULTN
authsource)getr   )usernamepassworddatabaseoptions	mechanismsources         V/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/pymongo/client_options.py_parse_credentialsr+   ,   sD     O(YMI[[&F9'	68XwX`aa    c                    d| v r| d   S | j                  dd      }t        |      }| j                  d      }| j                  dd      }t        |||      S )zParse read preference options.read_preferencereadpreferenceprimaryreadpreferencetagsmaxstalenessseconds)r#   r   r   )r'   namemodetagsmax_stalenesss        r*   _parse_read_preferencer8   7   s`    G#());;'3D#D)D;;+,DKK 5r:MdM::r,   c                    | j                  d      }| j                  d      }| j                  d      }| j                  d      }t        ||||      S )zParse write concern options.w
wtimeoutmsjournalfsync)r#   r   )r'   concernwtimeoutjr=   s        r*   _parse_write_concernrA   C   sK    kk#G{{<(HIAKK E1e44r,   c                :    | j                  d      }t        |      S )zParse read concern options.readconcernlevel)r#   r   )r'   r>   s     r*   _parse_read_concernrD   L   s    kk,-Gwr,   c           	     F   | j                  d      }|t        d|       | j                  d      }| j                  d      }| j                  d      }| j                  d      }| j                  dd      }| j                  d	d      }| j                  d
d      }g }	dD ]  }
|
| v s| |
   s|	j                  |
         dD ]  }
|
| v s| |
   r|	j                  |
         |	r$|d}n|st        ddj	                  |	      z        |rt        |||||||      }||fS d|fS )zParse ssl options.tlsNtlscertificatekeyfiletlscertificatekeyfilepassword	tlscafile
tlscrlfiletlsallowinvalidcertificatesFtlsallowinvalidhostnamestlsdisableocspendpointcheck)rG   rH   rI   rJ   )rK   rL   rM   TzmTLS has not been enabled but the following tls parameters have been set: %s. Please set `tls=True` or remove.z, )r#   r   appendr   joinr   )r'   use_tlscertfile
passphraseca_certscrlfileallow_invalid_certificatesallow_invalid_hostnamesdisable_ocsp_endpoint_checkenabled_tls_optsoptctxs               r*   _parse_ssl_optionsr[   R   sg   kk% G({{23H<=J{{;'Hkk,'G!(-JE!R%kk*DeL")++.KU"S ) '>gcl##C() ) '>'#,##C() ?G$79=CS9TU  &#'
 +++(((r,   c                   t        | |||      }|j                  dt        j                        }|j                  dt        j                        }|j                  dt        j
                        }|||kD  rt        d      |j                  dt        j                        }|j                  d      }	|j                  dt        j                        }
t        t        t        t              |j                  d            }|j                  d	      }|j                  d
      }|j                  d      }t        |j                  dg       |j                  dd            }t        |      \  }}|j                  d      }|j                  dt        j                        }t!        |||||	|
||t#        |      |||||||      S )zParse connection pool options.maxpoolsizeminpoolsizemaxidletimemsz3minPoolSize must be smaller or equal to maxPoolSizeconnecttimeoutmssockettimeoutmswaitqueuetimeoutmsevent_listenersappnamedriver
server_apicompressorszlibcompressionlevelr3   loadbalancedmaxconnecting)max_connectingrf   load_balancedcredentials)r+   r#   r   MAX_POOL_SIZEMIN_POOL_SIZEMAX_IDLE_TIME_SEC
ValueErrorCONNECT_TIMEOUTWAIT_QUEUE_TIMEOUTr	   r   r   r   r   r[   MAX_CONNECTINGr   r   )r$   r%   r&   r'   rm   max_pool_sizemin_pool_sizemax_idle_time_secondsconnect_timeoutsocket_timeoutwait_queue_timeoutrc   rd   re   rf   compression_settingsssl_contexttls_allow_invalid_hostnamesrl   rk   s                       r*   _parse_pool_optionsr~      s    %Xx7KKKKv/C/CDMKKv/C/CDM#KK9Q9QR ]]%BNOOkk"4f6L6LMO[[!23N %96;T;TU8H^$<=w{{K\?]^Okk)$G[["F\*J.M2&4JB(O 0B'/J,K,KK/M[[&2G2GHN#(%#! r,   c                     e Zd ZdZ	 	 	 	 	 	 	 	 ddZedd       Zedd       Zedd       Zedd       Z	edd       Z
edd       Zedd	       Zedd
       Zedd       Zedd       Zed d       Zed!d       Zed"d       Zed#d       Zed$d       Zed$d       Zed%d       Zedd       Zed&d       Zed'd       Zy)(ClientOptionszRead only configuration options for a MongoClient.

    Should not be instantiated directly by application developers. Access
    a client's options via :attr:`pymongo.mongo_client.MongoClient.options`
    instead.
    c                   || _         t        |      | _        |j                  d      | _        |j                  dt
        j                        | _        |j                  dt
        j                        | _	        t        ||||      | _        t        |      | _        |j                  d      | _        t        |      | _        t#        |      | _        |j                  d      | _        |j                  dt
        j(                        | _        |j                  dt
        j,                        | _        |j                  dt
        j0                        | _        |j                  d	t4              | _        |j                  d
      | _        |j                  d      | _        |j                  d      | _        |j                  dt
        j>                        | _         y )Ndirectconnectionlocalthresholdmsserverselectiontimeoutms
replicasetconnectheartbeatfrequencymsretrywrites
retryreadsserver_selectorauto_encryption_optsri   	timeoutmsservermonitoringmode)!_ClientOptions__optionsr
   _ClientOptions__codec_optionsr#   !_ClientOptions__direct_connectionr   LOCAL_THRESHOLD_MS"_ClientOptions__local_threshold_msSERVER_SELECTION_TIMEOUT(_ClientOptions__server_selection_timeoutr~   _ClientOptions__pool_optionsr8   _ClientOptions__read_preference _ClientOptions__replica_set_namerA   _ClientOptions__write_concernrD   _ClientOptions__read_concern_ClientOptions__connectHEARTBEAT_FREQUENCY#_ClientOptions__heartbeat_frequencyRETRY_WRITES_ClientOptions__retry_writesRETRY_READS_ClientOptions__retry_readsr   _ClientOptions__server_selector$_ClientOptions__auto_encryption_opts_ClientOptions__load_balanced_ClientOptions__timeoutSERVER_MONITORING_MODE&_ClientOptions__server_monitoring_mode)selfr$   r%   r&   r'   s        r*   __init__zClientOptions.__init__   sp    !3G<#*;;/A#B $+KK0BFD]D]$^! +2++&(G(G+
' 2(HhPWX!7!@")++l";3G<1': Y/%,[[1GIcIc%d"%kk-9L9LM$[[v7I7IJ!(->@S!T&-kk2H&I#&{{>: [1(/"F$A$A)
%r,   c                    | j                   S )z7The original options used to create this ClientOptions.)r   r   s    r*   _optionszClientOptions._options        ~~r,   c                    | j                   S )z>Whether to begin discovering a MongoDB topology automatically.)r   r   s    r*   r   zClientOptions.connect   r   r,   c                    | j                   S )z5A :class:`~bson.codec_options.CodecOptions` instance.)r   r   s    r*   codec_optionszClientOptions.codec_options        ###r,   c                    | j                   S )z:Whether to connect to the deployment in 'Single' topology.)r   r   s    r*   direct_connectionzClientOptions.direct_connection   s     '''r,   c                    | j                   S )z&The local threshold for this instance.)r   r   s    r*   local_threshold_msz ClientOptions.local_threshold_ms   s     (((r,   c                    | j                   S )z:The server selection timeout for this instance in seconds.)r   r   s    r*   server_selection_timeoutz&ClientOptions.server_selection_timeout   s     ...r,   c                    | j                   S )N)r   r   s    r*   r   zClientOptions.server_selector   s    %%%r,   c                    | j                   S )z$The monitoring frequency in seconds.)r   r   s    r*   heartbeat_frequencyz!ClientOptions.heartbeat_frequency   s     )))r,   c                    | j                   S )z.A :class:`~pymongo.pool.PoolOptions` instance.)r   r   s    r*   pool_optionszClientOptions.pool_options       """r,   c                    | j                   S )zA read preference instance.)r   r   s    r*   r.   zClientOptions.read_preference	  s     %%%r,   c                    | j                   S )zReplica set name or None.)r   r   s    r*   replica_set_namezClientOptions.replica_set_name  s     &&&r,   c                    | j                   S )z8A :class:`~pymongo.write_concern.WriteConcern` instance.)r   r   s    r*   write_concernzClientOptions.write_concern  r   r,   c                    | j                   S )z6A :class:`~pymongo.read_concern.ReadConcern` instance.)r   r   s    r*   read_concernzClientOptions.read_concern  r   r,   c                    | j                   S )z_The configured timeoutMS converted to seconds, or None.

        .. versionadded:: 4.2
        )r   r   s    r*   timeoutzClientOptions.timeout  s     ~~r,   c                    | j                   S )z9If this instance should retry supported write operations.)r   r   s    r*   retry_writeszClientOptions.retry_writes%  r   r,   c                    | j                   S )z8If this instance should retry supported read operations.)r   r   s    r*   retry_readszClientOptions.retry_reads*  s     !!!r,   c                    | j                   S )z:A :class:`~pymongo.encryption.AutoEncryptionOpts` or None.)r   r   s    r*   r   z"ClientOptions.auto_encryption_opts/  s     ***r,   c                    | j                   S )z@True if the client was configured to connect to a load balancer.)r   r   s    r*   rl   zClientOptions.load_balanced4  r   r,   c                z    | j                   j                  J | j                   j                  j                         S )zThe event listeners registered for this client.

        See :mod:`~pymongo.monitoring` for details.

        .. versionadded:: 4.0
        )r   _event_listenersrc   r   s    r*   rc   zClientOptions.event_listeners9  s7     ""33???""33CCEEr,   c                    | j                   S )zSThe configured serverMonitoringMode option.

        .. versionadded:: 4.5
        )r   r   s    r*   server_monitoring_modez$ClientOptions.server_monitoring_modeD  s     ,,,r,   N)r$   strr%   r   r&   Optional[str]r'   Mapping[str, Any])returnr   )r   zOptional[bool])r   r   )r   int)r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   zOptional[float])r   bool)r   zOptional[AutoEncryptionOpts])r   zlist[_EventListeners])r   r   )__name__
__module____qualname____doc__r   propertyr   r   r   r   r   r   r   r   r   r.   r   r   r   r   r   r   r   rl   rc   r    r,   r*   r   r      s   

'*
6C
N_
:     $ $ ( ( ) ) / / & & * * # # & & ' ' $ $ # #   # # " " + + $ $ F F - -r,   r   N)
r$   r   r%   r   r&   r   r'   r   r   zOptional[MongoCredential])r'   r   r   r   )r'   r   r   r   )r'   r   r   r   )r'   r   r   z!tuple[Optional[SSLContext], bool])
r$   r   r%   r   r&   r   r'   r   r   r   )5r   
__future__r   typingr   r   r   r   r   r	   bson.codec_optionsr
   pymongor   pymongo.authr   r   pymongo.compression_supportr   pymongo.errorsr   pymongo.monitoringr   r   pymongo.poolr   pymongo.read_concernr   pymongo.read_preferencesr   r   r   pymongo.server_selectorsr   pymongo.ssl_supportr   pymongo.write_concernr   r   r   pymongo.encryption_optionsr   pymongo.pyopenssl_contextr   pymongo.topology_descriptionr   r+   r8   rA   rD   r[   r~   r   r   r,   r*   <module>r      s    + " H H 3  B ; - > $ , 
 9 / @/=4< ,9DU	;5 8)v(( (,9(DU((VR- R-r,   