
    ,h                        d Z ddl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 ddl	m
Z
 ej                  efZd	efd
Zddeeeedf   dee   d	ee   fdZdeded	efdZddedee   d	efdZdeeef   d	efdZdee   d	ee   fdZy)zThe Utils methods.    N)Iterable)List)Optional)Union)AnyKey)Keysreturnc                      t        j                   t         j                  t         j                        } | j                  d       | j	                  d       | j                         d   }| j                          |S )z%Determines a free port using sockets.)z	127.0.0.1r         )socketAF_INETSOCK_STREAMbindlistengetsocknameclose)free_socketports     a/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/selenium/webdriver/common/utils.py	free_portr      s]    --0B0BCK%&q'')!,DK    hostr   c                     	 t        j                  | d      }d}|D ]V  \  }}}}}d}|rt        ||d         }|r|t         j                  k(  r|d   c S |s;|r>|t         j
                  k(  sR|d   }X |S # t         j                  $ r Y yw xY w)a  Resolve a hostname to an IP, preferring IPv4 addresses.

    We prefer IPv4 so that we don't change behavior from previous IPv4-only
    implementations, and because some drivers (e.g., FirefoxDriver) do not
    support IPv6 connections.

    If the optional port number is provided, only IPs that listen on the given
    port are considered.

    :Args:
        - host - A hostname.
        - port - Optional port number.

    :Returns:
        A single IP address, as a string. If any IPv4 address is found, one is
        returned. Otherwise, if any IPv6 address is found, one is returned. If
        neither, then None is returned.
    NTr   )r   getaddrinfogaierroris_connectabler   AF_INET6)r   r   	addrinfosipfamily_sockaddrconnectables           r   find_connectable_ipr%   )   s    &&&tT2	 
B%. !1a(x{;K6V^^3A;rf&?!B I ?? s   A7 7BBc                 J    d| v r| j                  d      sd|  d| S |  d| S )zJoins a hostname and port together.

    This is a minimal implementation intended to cope with IPv6 literals. For
    example, _join_host_port('::1', 80) == '[::1]:80'.

    :Args:
        - host - A hostname.
        - port - An integer port.
    :[z]:)
startswith)r   r   s     r   join_host_portr*   N   s:     d{4??3/4&4&!!V1TFr   c                 t   d}	 t        j                  || fd      }d}|r0	 |j                  t         j                         |j                          |S # t        $ r d}Y Aw xY w# t
        $ r Y .w xY w# |rA	 |j                  t         j                         n# t
        $ r Y nw xY w|j                          w w xY w)zsTries to connect to the server at port to see if it is running.

    :Args:
     - port - The port to connect.
    Nr   TF)r   create_connection_is_connectable_exceptionsshutdown	SHUT_RDWR	Exceptionr   )r   r   socket_results       r   r   r   ]   s     G**D$<;   !1!12 MMOM &      !1!12 MMO sX   A A# A A2 A  A2 #	A/.A/2B76BB7	B"B7!B""B7c                 ~    ddl m} 	 |j                  d|  d      }|j                         dk(  S # t        $ r Y yw xY w)zTries to connect to the HTTP server at /status path and specified port
    to see if it responds successfully.

    :Args:
     - port - The port to connect.
    r   )requestzhttp://127.0.0.1:z/status   F)urllibr4   urlopengetcoder0   )r   url_requestress      r   is_url_connectabler;   s   sI     .!!$5dV7"CD{{}## s   '0 	<<valuec                     g }| D ]f  }t        |t              r|j                  |       %t        |t        t        f      r|j                  t        |             V|j                  |       h |S )z7Processes the values that will be typed in the element.)
isinstancer   appendintfloatextendstr)r<   
charactersvals      r   keys_to_typingrF      sd    J #c4 c"c5\*c#h'c"# r   )N)	localhost)__doc__r   typingr   r   r   r   selenium.typesr   selenium.webdriver.common.keysr   errorConnectionResetErrorr-   r@   r   rC   bytes	bytearrayr%   r*   boolr   r;   rF    r   r   <module>rR      s   "       ! /$ll,@A 3 "eC	4$?@ "QT "aijman "J C C  HSM D ,U38_   (6* tCy r   