
    j*                       d dl mZ d dlZd dlZd dlmZmZmZm	Z	 ej
        rd dlZ ej        d          Z ej        d          Zej
        r G d dej                  Z G d d	 ee                    Z G d
 dee          Z G d de          Z G d de          Z G d de          Z G d dee          Z G d dee          ZdS )    )annotationsN)AddressFamilyAF_INETAF_INET6getservbynameneo4j_Tc                      e Zd ZddZdS )_WithPeerNamereturntuplec                    d S N selfs    Z/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/neo4j/addressing.pygetpeernamez_WithPeerName.getpeername*   s          N)r   r   )__name__
__module____qualname__r   r   r   r   r   r   )   s        ++++++r   r   c                  P     e Zd Z fdZd Zed             Zed             Z xZS )_AddressMetac                V     t                      j        |i | d | _        d | _        d S r   )super__init__	_ipv4_cls	_ipv6_cls)clsargskwargs	__class__s      r   r   z_AddressMeta.__init__/   s1    $)&)))r   c                      fd                                  D             }t          |          dk    r$t          d                     |                    |d         S )Nc                ^    g | ])}|j         j         k    rt          |d d          k    '|*S )familyN)r   getattr).0scr&   r   s     r   
<listcomp>z4_AddressMeta._subclass_by_family.<locals>.<listcomp>5   sI     
 
 
00B$//699 999r      zfClass {} needs exactly one direct subclass with attribute `family == {}` within this module. Found: {}r   )__subclasses__len
ValueErrorformat)r   r&   
subclassess   `` r   _subclass_by_familyz _AddressMeta._subclass_by_family4   s    
 
 
 
 
,,..
 
 


 z??a"F4<<  
 !}r   c                \    | j         |                     t                    | _         | j         S r   )r   r1   r   r   s    r   ipv4_clsz_AddressMeta.ipv4_clsB   s'    >!!55g>>DN~r   c                \    | j         |                     t                    | _         | j         S r   )r   r1   r   r   s    r   ipv6_clsz_AddressMeta.ipv6_clsH   s'    >!!55h??DN~r   )	r   r   r   r   r1   propertyr3   r5   __classcell__r#   s   @r   r   r   -   s}            
     X
   X    r   r   c                      e Zd ZU dZdZded<   ddZedd            Ze	 	 d d!d            Z	edddd"d            Z
d Zed#d            Zed#d            Zed#d            Zed$d            Zed%d            ZdS )&Addressae  Base class to represent server addresses within the driver.

    A tuple of two (IPv4) or four (IPv6) elements, representing the address
    parts. See also python's :mod:`socket` module for more information.

        >>> Address(("example.com", 7687))
        IPv4Address(('example.com', 7687))
        >>> Address(("127.0.0.1", 7687))
        IPv4Address(('127.0.0.1', 7687))
        >>> Address(("::1", 7687, 0, 0))
        IPv6Address(('::1', 7687, 0, 0))

    :param iterable: A collection of two or four elements creating an
        :class:`.IPv4Address` or :class:`.IPv6Address` instance respectively.
    Nzt.Optional[AddressFamily]r&   iterablet.Collectionr   c                    t          ||           r|S t          |          }t                              | |          }|dk    r| j        |_        n"|dk    r| j        |_        nt          d          |S )N      zFAddresses must consist of either two parts (IPv4) or four parts (IPv6))
isinstancer-   r   __new__r3   r#   r5   r.   )r    r;   n_partsinsts       r   rA   zAddress.__new__c   s    h$$ 	Oh--}}S(++a<< \DNN\\ \DNN E F F Fr   socketr   c                @    |                                 } | |          S )zCreate an address from a socket object.

        Uses the socket's ``getpeername`` method to retrieve the remote
        address the socket is connected to.
        )r   )r    rD   addresss      r   from_socketzAddress.from_socketq   s#     $$&&s7||r   sstrdefault_hostt.Optional[str]default_portt.Optional[int]c                
   t          |t                    st          d          |                    d          ru|dd                             d          \  }}}|                    d          }	 t          |          }n# t          t          f$ r Y nw xY w | |p|pd|p|pdddf          S |                    d          \  }}}	 t          |          }n# t          t          f$ r Y nw xY w | |p|pd|p|pdf          S )	a  Parse a string into an address.

        The string must be in the format ``host:port`` (IPv4) or
        ``[host]:port`` (IPv6).
        If no port is specified, or is empty, ``default_port`` will be used.
        If no host is specified, or is empty, ``default_host`` will be used.

            >>> Address.parse("localhost:7687")
            IPv4Address(('localhost', 7687))
            >>> Address.parse("[::1]:7687")
            IPv6Address(('::1', 7687, 0, 0))
            >>> Address.parse("localhost")
            IPv4Address(('localhost', 0))
            >>> Address.parse("localhost", default_port=1234)
            IPv4Address(('localhost', 1234))

        :param s: The string to parse.
        :param default_host: The default host to use if none is specified.
            :data:`None` indicates to use ``"localhost"`` as default.
        :param default_port: The default port to use if none is specified.
            :data:`None` indicates to use ``0`` as default.

        :return: The parsed address.
        z(Address.parse requires a string argument[r+   N]:	localhostr   )	r@   rI   	TypeError
startswith
rpartitionlstripintr.   	partition)r    rH   rJ   rL   host_ports          r   parsezAddress.parse~   s]   > !S!! 	HFGGG<< 	4 abbE,,S11MD!T;;s##D4yyz*   3;;111a9 : : : KK,,MD!T4yyz*   3;;113 4 4 4s$   1B BB	C C-,C-)rJ   rL   t.List[Address]c                    t          d |D                       st          d           fdd                    |                                          D             S )ae  Parse multiple addresses into a list.

        See :meth:`.parse` for details on the string format.

        Either a whitespace-separated list of strings or multiple strings
        can be used.

            >>> Address.parse_list("localhost:7687", "[::1]:7687")
            [IPv4Address(('localhost', 7687)), IPv6Address(('::1', 7687, 0, 0))]
            >>> Address.parse_list("localhost:7687 [::1]:7687")
            [IPv4Address(('localhost', 7687)), IPv6Address(('::1', 7687, 0, 0))]

        :param s: The string(s) to parse.
        :param default_host: The default host to use if none is specified.
            :data:`None` indicates to use ``"localhost"`` as default.
        :param default_port: The default port to use if none is specified.
            :data:`None` indicates to use ``0`` as default.

        :return: The list of parsed addresses.
        c              3  @   K   | ]}t          |t                    V  d S r   )r@   rI   )r(   s0s     r   	<genexpr>z%Address.parse_list.<locals>.<genexpr>   s,      332:b#&&333333r   z-Address.parse_list requires a string argumentc                >    g | ]}                     |          S r   )r\   )r(   ar    rJ   rL   s     r   r*   z&Address.parse_list.<locals>.<listcomp>   s9     . . . 		!\<88 . . .r    )allrS   joinsplit)r    rJ   rL   rH   s   ``` r   
parse_listzAddress.parse_list   s    6 3333333 	MKLLL. . . . . .!**,,. . . 	.r   c                \    d                     | j        j        t          |                     S )Nz{}({!r}))r/   r#   r   r   r   s    r   __repr__zAddress.__repr__   s#      !8%++FFFr   t.Anyc                    | d         S )Nr   r   r   s    r   
_host_namezAddress._host_name   s    Awr   c                    | d         S )zThe host part of the address.

        This is the first part of the address tuple.

            >>> Address(("localhost", 7687)).host
            'localhost'
        r   r   r   s    r   rY   zAddress.host   s     Awr   c                    | d         S )ax  The port part of the address.

        This is the second part of the address tuple.

            >>> Address(("localhost", 7687)).port
            7687
            >>> Address(("localhost", 7687, 0, 0)).port
            7687
            >>> Address(("localhost", "7687")).port
            '7687'
            >>> Address(("localhost", "http")).port
            'http'
        r+   r   r   s    r   r[   zAddress.port   s     Awr   c                    | S r   r   r   s    r   _unresolvedzAddress._unresolved   s    r   rW   c                   t           }	 t          | d                   S # t          $ r
 t          }Y nt           $ r Y nw xY w	 t	          | d                   S # t          $ r
 t          }Y nt           $ r Y nw xY w |d| d         z            )a  The port part of the address as an integer.

        First try to resolve the port as an integer, using
        :meth:`socket.getservbyname`. If that fails, fall back to parsing the
        port as an integer.

            >>> Address(("localhost", 7687)).port_number
            7687
            >>> Address(("localhost", "http")).port_number
            80
            >>> Address(("localhost", "7687")).port_number
            7687
            >>> Address(("localhost", [])).port_number
            Traceback (most recent call last):
                ...
            TypeError: Unknown port value []
            >>> Address(("localhost", "banana-protocol")).port_number
            Traceback (most recent call last):
                ...
            ValueError: Unknown port value 'banana-protocol'

        :returns: The resolved port number.

        :raise ValueError: If the port cannot be resolved.
        :raise TypeError: If the port cannot be resolved.
        r+   zUnknown port value %r)rS   r   OSErrorr.   rW   )r   	error_clss     r   port_numberzAddress.port_number   s    8 &		 a))) 	# 	# 	#"III 	 	 	D		tAw<< 	# 	# 	#"III 	 	 	D	i/$q'9:::s(    =	==A A5)	A54A5)r;   r<   r   r:   )rD   r   r   r:   )NN)rH   rI   rJ   rK   rL   rM   r   r:   )rH   rI   rJ   rK   rL   rM   r   r]   )r   rk   r   r:   )r   rW   )r   r   r   __doc__r&   __annotations__rA   classmethodrG   r\   rh   rj   r6   rm   rY   r[   rq   ru   r   r   r   r:   r:   O   sy         " )-F,,,,    
 
 
 [
  )-(,	34 34 34 34 [34j  )-(,	. . . . . [.>G G G    X    X    X     X +; +; +; X+; +; +;r   r:   )	metaclassc                      e Zd ZdZeZddZdS )IPv4Addressa`  An IPv4 address (family ``AF_INET``).

    This class is also used for addresses that specify a host name instead of
    an IP address. E.g.,

        >>> Address(("example.com", 7687))
        IPv4Address(('example.com', 7687))

    This class should not be instantiated directly. Instead, use
    :class:`.Address` or one of its factory methods.
    r   rI   c                     dj         |  S )Nz{}:{}r/   r   s    r   __str__zIPv4Address.__str__9  s    w~t$$r   Nr   rI   )r   r   r   rw   r   r&   r   r   r   r   r|   r|   *  s9        
 
 F% % % % % %r   r|   c                      e Zd ZdZeZddZdS )IPv6AddresszAn IPv6 address (family ``AF_INETl``).

    This class should not be instantiated directly. Instead, use
    :class:`.Address` or one of its factory methods.
    r   rI   c                     dj         |  S )Nz[{}]:{}r~   r   s    r   r   zIPv6Address.__str__F  s    y&&r   Nr   )r   r   r   rw   r   r&   r   r   r   r   r   r   =  s9          F' ' ' ' ' 'r   r   c                  `     e Zd ZU ded<   ed	d            Zed
 fd            Zd fdZ xZS )ResolvedAddressrI   _unresolved_host_namer   c                    | j         S r   )r   r   s    r   rm   zResolvedAddress._host_nameN  s    ))r   r:   c                t    t                                          t          | j        g| dd          R           S )Nr+   )r   rA   r:   rm   )r   r#   s    r   rq   zResolvedAddress._unresolvedR  s0    www(D48(D(DEEEr   	host_namec                   t                                          | |          }t          j        t          |          }||_        |S r   )r   rA   tcastr   r   )r    r;   r   newr#   s       r   rA   zResolvedAddress.__new__V  s8    ggooc8,,f_c**$-!
r   r   rv   )r   rI   r   r   )	r   r   r   rx   r6   rm   rq   rA   r7   r8   s   @r   r   r   J  s         * * * X* F F F F F XF         r   r   c                      e Zd ZdS )ResolvedIPv4AddressNr   r   r   r   r   r   r   r   ]          Dr   r   c                      e Zd ZdS )ResolvedIPv6AddressNr   r   r   r   r   r   a  r   r   r   )
__future__r   loggingtypingr   rD   r   r   r   r   TYPE_CHECKINGtyping_extensionste	getLoggerlogTypeVarr	   Protocolr   typer   r   r:   r|   r   r   r   r   r   r   r   <module>r      s-  " # " " " " "                 ? #"""" g   QYt__ ? ,, , , , , , , ,    44;;   DX; X; X; X; X;e| X; X; X; X;v% % % % %' % % %&
' 
' 
' 
' 
'' 
' 
' 
'    g   &	 	 	 	 	+ 	 	 		 	 	 	 	+ 	 	 	 	 	r   