
    Rǻi*3                       d dl mZ d dlmZ ddlmZ ddlmZm	Z	 ddl
mZmZ ddlmZ d Z G d	 d
      Z G d de      Z G d de      Z G d de      Z G d d      Z G d d      Z G d d      Z G d d      Z G d de      Z G d dej2                  e      Z G d de      Z G d  d!e      Z G d" d#e      Z G d$ d%e      Zy&)'    )annotations)ABCMeta   )_typing)deprecation_warnpreview_warn)DEFAULT_DATABASEWRITE_ACCESS)ConfigurationErrorc              #  f   K   t        | d      r| D ]  }|| |   f  y| D ]  \  }}||f  yw)a  
    Iterate through key-value pairs of a dict-like object.

    If the object has a ``keys`` method, this is used along with
    ``__getitem__`` to yield each pair in turn. If no ``keys`` method exists,
    each iterable element is assumed to be a 2-tuple of key and value.
    keysN)hasattr)iterablekeyvalues      I/opt/lhia/marcimex/agent/venv/lib/python3.12/site-packages/neo4j/_conf.py
iter_itemsr   !   sO      x  	%Cx}$$	% # 	JCu*	s   /1c                      e Zd Zy)
TrustStoreN)__name__
__module____qualname__     r   r   r   1   s    r   r   c                      e Zd ZdZy)TrustSystemCAsa  
    Used to configure the driver to trust system CAs (default).

    Trust server certificates that can be verified against the system
    certificate authority. This option is primarily intended for use with
    full certificates.

    The driver loads the trusted system CAs using Python's
    :meth:`ssl.SSLContext.load_default_certs`.

    For example::

        import neo4j

        driver = neo4j.GraphDatabase.driver(
            url, auth=auth, trusted_certificates=neo4j.TrustSystemCAs()
        )
    Nr   r   r   __doc__r   r   r   r   r   6   s    r   r   c                      e Zd ZdZy)TrustAlla  
    Used to configure the driver to trust all certificates.

    Trust any server certificate. This ensures that communication
    is encrypted but does not verify the server certificate against a
    certificate authority. This option is primarily intended for use with
    the default auto-generated server certificate.

    .. warning::
        This still leaves you vulnerable to man-in-the-middle attacks. It will
        just prevent eavesdropping "from the side-line" (i.e., without
        intercepting the connection).

    For example::

        import neo4j

        driver = neo4j.GraphDatabase.driver(
            url, auth=auth, trusted_certificates=neo4j.TrustAll()
        )
    Nr   r   r   r   r    r    K   s    r   r    c                      e Zd ZdZddZy)TrustCustomCAsa  
    Used to configure the driver to trust custom CAs.

    Trust server certificates that can be verified against the certificate
    authority at the specified paths. This option is primarily intended for
    self-signed and custom certificates.

    :param certificates: paths to the certificates to trust.
        Those are not the certificates you expect to see from the server but
        the CA certificates you expect to be used to sign the server's
        certificate.

    For example::

        import neo4j

        driver = neo4j.GraphDatabase.driver(
            url, auth=auth,
            trusted_certificates=neo4j.TrustCustomCAs(
                "/path/to/ca1.crt", "/path/to/ca2.crt",
            )
        )
    c                    || _         y N)certs)selfcertificatess     r   __init__zTrustCustomCAs.__init__|   s	    !
r   N)r'   strr   r   r   r   r(   r   r   r   r"   r"   c   s    0"r   r"   c                      e Zd ZdZd Zy)DeprecatedAliasz+Used when a config option has been renamed.c                    || _         y r$   )new)r&   r.   s     r   r(   zDeprecatedAlias.__init__   s	    r   Nr*   r   r   r   r,   r,      s
    5r   r,   c                      e Zd ZdZddZy)DeprecatedAlternativezCUsed for deprecated config options that have a similar alternative.Nc                     || _         || _        y r$   )r.   	converter)r&   r.   r2   s      r   r(   zDeprecatedAlternative.__init__   s    "r   r$   r*   r   r   r   r0   r0      s
    M#r   r0   c                      e Zd ZdZd Zy)DeprecatedOptionz7Used for deprecated config options without alternative.c                    || _         y r$   r   r&   r   s     r   r(   zDeprecatedOption.__init__   	    
r   Nr*   r   r   r   r4   r4      s
    Ar   r4   c                      e Zd ZdZd Zy)PreviewOptionz#Used for config options in preview.c                    || _         y r$   r6   r7   s     r   r(   zPreviewOption.__init__   r8   r   Nr*   r   r   r   r:   r:      s
    -r   r:   c                       e Zd Z fdZ xZS )
ConfigTypec                   g i i i i |D ]  }t        |      | u s|j                         z  j                  |j                                j                  |j	                                j                  |j                                j                  |j                                 |j                         D ]  \  }}|j                  d      s!t        |      st        |t        t        f      r9t        |t              r|j                  |<   Yt        |t              r|j                  |j                   f|<   j#                  |       t        |t$              r|j&                  |<   |j&                  ||<   t        |t(              s|j&                  |<   |j&                  ||<    fd}fd}fd}	fd}
fd}fd}fd}||	||
|||fD ]'  }|j+                  |j,                  t        |             ) t.        | a  | |||j                         D ci c]  \  }}| |d       vr|| c}}      S c c}}w )	N_c                    t              S r$   )set)r?   fieldss    r   r   z ConfigType.__new__.<locals>.keys   s    v;r   c                r    t        j                               }t        j                               }||z  S r$   )rA   r   )r?   aliasesalternativesdeprecated_aliasesdeprecated_alternativess      r   _deprecated_keysz,ConfigType.__new__.<locals>._deprecated_keys   s6    ,1134G6;;=>L\))r   c                N    j                  |j                  |d      d         S )Nr$   r   )get)r?   r   rF   rG   s     r   _get_newz$ConfigType.__new__.<locals>._get_new   s.    %)),00g>qA r   c                    S r$   r   )r?   rF   s    r   _deprecated_aliasesz/ConfigType.__new__.<locals>._deprecated_aliases   	    %%r   c                    S r$   r   )r?   rG   s    r   _deprecated_alternativesz4ConfigType.__new__.<locals>._deprecated_alternatives   s	    **r   c                    S r$   r   )r?   deprecated_optionss    r   _deprecated_optionsz/ConfigType.__new__.<locals>._deprecated_options   rN   r   c                    S r$   r   )r?   preview_optionss    r   _preview_optionsz,ConfigType.__new__.<locals>._preview_options   s	    ""r   )typer   updaterM   rP   rS   rV   items
startswithcallable
isinstancestaticmethodclassmethodr,   r.   r0   r2   appendr4   r   r:   
setdefaultr   super__new__)mcsnamebases
attributesbasekvr   rH   rK   rM   rP   rS   rV   funcrF   rG   rR   rB   rU   	__class__s                  @@@@@r   rb   zConfigType.__new__   sK   "$ 	@DDzS $))+%"))$*B*B*DE'..t/L/L/NO"))$*B*B*DE&&t'<'<'>?	@ $$& 	DAqS!A;a,!<=!_-()"1%!23-.UUAKK-?'*MM!!-.()"1% !
1!]+%&WW" !
1+	.		*
	
	&	+	&	# $
 		DD !!$--T1BC		D w ',,.Aq,T22 1		
 		
s   2I)r   r   r   rb   __classcell__)rk   s   @r   r=   r=      s    S
 S
r   r=   c                  f    e Zd ZdZed        Zed        Zed        ZddZ	d Z
d Zd Zd	 Zd
 Zy)Configz,Base class for all configuration containers.c                    g }|D ]@  }t        |t              st        |d      |j                  |j	                  |              B | r+t        ddj                  | j                                      |S )Nz is not a Config subclassUnexpected config keys: , )
issubclassrn   	TypeErrorr_   _consumer   joinr   )dataconfig_classesvaluesconfig_classs       r   consume_chainzConfig.consume_chain   s~    * 	7LlF3<"22K LMMMM,//56	7 $*499TYY[+A*BC  r   c                .    | j                  ||       \  }|S r$   )rz   )clsrv   configs      r   consumezConfig.consume  s    %%dC0	r   c                    i }|r=| j                         | j                         z  D ]  }	 |j                  |      }|||<     | |      S # t        $ r Y /w xY wr$   )r   rH   popKeyError)r|   rv   r}   r   r   s        r   rt   zConfig._consume	  sj    xxzC$8$8$:: (( HHSME #(F3K( 6{	   s   A

	AAc                @    t        t        |             fdg }j                         D ]  \  }}|		  ||        |rt        ddj                  |      z         y # t        $ r,}|j                  |fk(  s |j                  |       Y d }~ed }~ww xY w)Nc                   | j                         v rTr!| j                         v rt        d|  d       r!| j                         v rt	        d|  d       t        | |       y | j                         v rwj                  |       }|v rt        d| d|  d      rt        d|  d| d       | j                         v r
 ||       y j                         |    \  }} ||       y t        |       )	NzThe 'z' config key is deprecated.z^' config key is in preview. It might be changed or removed any time even without prior notice.zCannot specify both 'z' and 'z' in configz(' config key is deprecated, please use 'z	' instead)r   rS   r   rV   r   setattrrH   rK   r   rM   rP   AttributeError)	rh   ri   k0r?   r2   	data_dictr&   set_attrwarns	        r   r   z!Config.__update.<locals>.set_attr  s"   DIIKA!9!9!;;$uQC/J%KLA!6!6!88 s #( (
 a#d++--]]1%?,/t71#[I  $s #4y* 0022RO#'#@#@#B1#ELAydA&$Q''r   rp   rq   )dictr   rY   r   argsr_   r   ru   )	r&   rv   r   rejected_keysr   r   excr   r   s	   ` `    @@r   __updatezConfig.__update  s    D)*		(< #//+ 	.JC .S%(	. $*TYY}-EE   & .88v-!((--.s   	A((	B1"BBc                    |D ]7  }t        |t              r| j                  |d       '| j                  |       9 | j                  |       y )NF)r   )r\   rn   _Config__update)r&   r   kwargsargs       r   r(   zConfig.__init__F  sE     	#C#v&c.c"		#
 	fr   c           
         | D cg c]  }d| dt        | |       }}d| j                  j                   dj                  |       dS c c}w )N =< >)getattrrk   r   ru   )r&   r   attrss      r   __repr__zConfig.__repr__N  sW    =ABc1SE74-01BB4>>**+BGGEN+;1== Cs   Ac                4    t        | j                               S r$   )lenr   r&   s    r   __len__zConfig.__len__R  s    499;r   c                    t        | |      S r$   )r   )r&   r   s     r   __getitem__zConfig.__getitem__U  s    tS!!r   c                4    t        | j                               S r$   )iterr   r   s    r   __iter__zConfig.__iter__X  s    DIIK  r   N)T)r   r   r   r   r]   rz   r^   r~   rt   r   r(   r   r   r   r   r   r   r   rn   rn      s^    6
 
   
 
.`> "!r   rn   )	metaclassc                  8    e Zd ZdZdZdZdZdZdZe	Z
dZdZdZdZy)	WorkspaceConfigzWorkSpace configuration.g      N@      >@g      ?g       @g?i  N)r   r   r   r   connection_acquisition_timeoutmax_transaction_retry_timeinitial_retry_delayretry_delay_multiplierretry_delay_jitter_factorr	   database
fetch_sizeimpersonated_userbookmark_managerwarn_notification_severityr   r   r   r   r   \  sS    " &*" "&
  ! !$  H
 J   "&r   r   c                  $    e Zd ZdZdZeZdZdZdZ	y)SessionConfigzSession configuration.N)
r   r   r   r   	bookmarksr
   default_access_modeauthnotifications_min_severity&notifications_disabled_classificationsr   r   r   r   r     s+      I ' D "& .2*r   r   c                      e Zd ZdZdZdZy)TransactionConfigz
    Transaction configuration. This is internal for now.

    neo4j.session.begin_transaction
    neo4j.Query
    neo4j.unit_of_work

    are both using the same settings.
    N)r   r   r   r   metadatatimeoutr   r   r   r   r     s     H Gr   r   c                      e Zd ZdZdZy)RoutingConfigz7Neo4jDriver routing settings. This is internal for now.r   N)r   r   r   r   routing_table_purge_delayr   r   r   r   r     s    A !%r   r   N)
__future__r   abcr   r   r   t	_warningsr   r   apir	   r
   
exceptionsr   r   r   r   r    r"   r,   r0   r4   r:   r=   Mappingrn   r   r   r   r   r   r   r   <module>r      s   " #   + 	 	
Z *z 0"Z ": # #  T
 T
ne!QYY* e!P*&f *&Z2O 2& $%F %r   