
    vKg                     &   S r SSKrSSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  \R                  \4rS	\4S
 jrSS\\\\S4   S\\   S	\\   4S jjrS\S\S	\4S jrSS\S\\   S	\4S jjrS\\\4   S	\4S jrS\\   S	\\   4S jrg)zThe Utils methods.    N)Iterable)List)Optional)Union)AnyKey)Keysreturnc                      [         R                   " [         R                  [         R                  5      n U R                  S5        U R	                  S5        U R                  5       S   nU R                  5         U$ )z%Determines a free port using sockets.)z	127.0.0.1r         )socketAF_INETSOCK_STREAMbindlistengetsocknameclose)free_socketports     _/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/selenium/webdriver/common/utils.py	free_portr      s]    --0B0BCK%&q'')!,DK    hostr   c                 V    [         R                  " U S5      nSnU Hn  u  n    pVSnU(       a  [        XS   5      nU(       a  U[         R                  :X  a  US   s  $ U(       d  MJ  U(       a  MS  U[         R
                  :X  d  Mi  US   nMp     U$ ! [         R                   a     gf = f)aL  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({;K6V^^3A;;rrf&?!B &/ I ?? s   B B('B(c                 X    SU ;   a  U R                  S5      (       d  SU  SU 3$ U  SU 3$ )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                     Sn [         R                  " X4S5      nSnU(       a  UR                  5         U$ ! [         a    Sn N'f = f! U(       a  UR                  5         f f = f)zgTries 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_exceptionsr   )r   r   socket_results       r   r   r   ]   sd     G**D<; MMOM &  MMO s!   7 AA	 AA	 	A#c                     SSK Jn   UR                  SU  S35      nUR                  5       S:H  $ ! [         a     gf = f)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)urllibr1   urlopengetcode	Exception)r   url_requestress      r   is_url_connectabler9   o   sI     .!!$5dV7"CD{{}## s   '0 
==valuec                     / nU  Hs  n[        U[        5      (       a  UR                  U5        M+  [        U[        [        45      (       a  UR                  [        U5      5        Mb  UR                  U5        Mu     U$ )z7Processes the values that will be typed in the element.)
isinstancer   appendintfloatextendstr)r:   
charactersvals      r   keys_to_typingrD      se    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   rA   bytes	bytearrayr%   r*   boolr   r9   rD    r   r   <module>rP      s   "       ! /$ll,@A 3 "eC	4$?@ "QT "aijman "J C C  HSM D $U38_   (6* tCy r   