
    ؄_$                         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	  G d
 de
          Zd Zd Zd Zd Zd ZdS )a  Provides the :class:`~sqlalchemy.engine.url.URL` class which encapsulates
information about a database connection specification.

The URL object is created automatically when
:func:`~sqlalchemy.engine.create_engine` is called with a string
argument; alternatively, the URL is a public-facing construct which can
be used directly and is also accepted directly by ``create_engine()``.
    N   )Dialect   )exc)util)plugins)registryc                       e Zd ZdZ	 	 	 	 	 	 ddZddZd Zd Zd Zd	 Z	d
 Z
ed             Zej        d             Zd Zd Zd Zd Zd Zg fdZdS )URLaX  
    Represent the components of a URL used to connect to a database.

    This object is suitable to be passed directly to a
    :func:`~sqlalchemy.create_engine` call.  The fields of the URL are parsed
    from a string by the :func:`.make_url` function.  The string
    format of the URL is an RFC-1738-style string.

    All initialization parameters are available as public attributes.

    :param drivername: the name of the database backend.
      This name will correspond to a module in sqlalchemy/databases
      or a third party plug-in.

    :param username: The user name.

    :param password: database password.

    :param host: The name of the host.

    :param port: The port number.

    :param database: The database name.

    :param query: A dictionary of options to be passed to the
      dialect and/or the DBAPI upon connect.

    Nc                     || _         || _        || _        || _        |t	          |          | _        nd | _        || _        |pi | _        d S N)
drivernameusernamepassword_originalhostintportdatabasequery)selfr   r   passwordr   r   r   r   s           Z/var/www/book.euthymeo.com/html/venv/lib/python3.11/site-packages/sqlalchemy/engine/url.py__init__zURL.__init__8   sS     % !)	D		DIIDI [b


    Tc                      j         dz   } j        A|t           j                  z  } j        |d|rdnt           j                  z   z  }|dz  } j        !d j        v r|d j        z  z  }n
| j        z  } j        |dt           j                  z   z  } j        |d j        z   z  } j        rOt           j                  }|
                                 |dd                     fd	|D                       z   z  }|S )
Nz://:z***@z[%s]/?&c              3      K   | ]Q}t          j        j        |                   D ]/}t          j        |          d t          j        |          V  0RdS )=N)r   to_listr   
quote_plus).0kelementr   s      r   	<genexpr>z$URL.__to_string__.<locals>.<genexpr>b   s          #|DJqM::      ?1----tw/G/G/GH             r   )r   r   _rfc_1738_quoter   r   r   strr   r   listsortjoin)r   hide_passwordskeyss   `   r   __to_string__zURL.__to_string__M   sD   Oe#=$///A}(S*NEE0N0N  HA9 diVdi''TY9 s49~~%%A=$t}$$A: 	
##DIIKKKsxx                 A
 r   c                 .    |                      d          S )NF)r.   r1   r   s    r   __str__zURL.__str__i   s    !!!666r   c                 *    |                                  S r   r3   r4   s    r   __repr__zURL.__repr__l   s    !!###r   c                 :    t          t          |                     S r   )hashr*   r4   s    r   __hash__zURL.__hash__o   s    CIIr   c                    t          |t                    oo| j        |j        k    o_| j        |j        k    oO| j        |j        k    o?| j        |j        k    o/| j        |j        k    o| j        |j        k    o| j        |j        k    S r   )	
isinstancer   r   r   r   r   r   r   r   r   others     r   __eq__z
URL.__eq__r   s    uc"" (5#33(/( /( 	UZ'	(
 /( 
ek)( 	UZ'		
r   c                     | |k     S r    r=   s     r   __ne__z
URL.__ne__~   s    5=  r   c                 F    | j         d S t          j        | j                   S r   )r   r   	text_typer4   s    r   r   zURL.password   s#    !)4>$"8999r   c                     || _         d S r   )r   )r   r   s     r   r   zURL.password   s    !)r   c                 b    d| j         vr| j         S | j                             d          d         S )N+r   )r   splitr4   s    r   get_backend_namezURL.get_backend_name   s2    do%%?"?((--a00r   c                     d| j         vr|                                 j        S | j                             d          d         S )NrG   r   )r   get_dialectdriverrH   r4   s    r   get_driver_namezURL.get_driver_name   s?    do%%##%%,,?((--a00r   c                      t          j         j                            dd                    }|                    dg           z  } fd|D             S )NpluginrA   r   c                 L    g | ] } t          j        |                    !S rA   )r   load)r%   plugin_namekwargsr   s     r   
<listcomp>z,URL._instantiate_plugins.<locals>.<listcomp>   s?     
 
 
 &GL%%dF33
 
 
r   )r   r#   r   get)r   rS   plugin_namess   `` r   _instantiate_pluginszURL._instantiate_plugins   sk    |DJNN8R$@$@AA

9b111
 
 
 
 
+
 
 
 	
r   c                    d| j         vr| j         }n| j                             dd          }t          j        |          }t	          |d          r;t          |j        t                    r!t          |j        t                    r|j        S |S )zReturn the "entry point" dialect class.

        This is normally the dialect itself except in the case when the
        returned class implements the get_dialect_cls() method.

        rG   .dialect)
r   replacer	   rQ   hasattrr<   rZ   type
issubclassr   )r   nameclss      r   _get_entrypointzURL._get_entrypoint   s     do%%?DD?**344DmD!!
 C##	3;--	 3;00	
 ;Jr   c                 X    |                                  }|                    |           }|S )zfReturn the SQLAlchemy database dialect class corresponding
        to this URL's driver name.
        )ra   get_dialect_cls)r   
entrypointdialect_clss      r   rK   zURL.get_dialect   s.     ))++
 0066r   c                     i }g d}|D ]O}|r|                     d          }n||v r	||         }n|}|$t          | |d          rt          | |          ||<   P|S )a2  Translate url attributes into a dictionary of connection arguments.

        Returns attributes of this url (`host`, `database`, `username`,
        `password`, `port`) as a plain dictionary.  The attribute names are
        used as the keys by default.  Unset or false attributes are omitted
        from the final dictionary.

        :param \**kw: Optional, alternate key names for url attributes.

        :param names: Deprecated.  Same purpose as the keyword-based alternate
            names, but correlates the name to the original positionally.
        )r   r   r   r   r   r   NF)popgetattr)r   nameskw
translatedattribute_namessnamer_   s          r   translate_connect_argszURL.translate_connect_args   s     
NNN$ 	8 	8E yy||"%yGD%$?$?#*4#7#7
4 r   )NNNNNN)T)__name__
__module____qualname____doc__r   r1   r5   r7   r:   r?   rB   propertyr   setterrI   rM   rW   ra   rK   rn   rA   r   r   r   r      sB        @ ! ! ! !*   87 7 7$ $ $  

 

 

! ! ! : : X: _* * _*1 1 11 1 1
 
 
  0   ,.      r   r   c                 X    t          | t          j                  rt          |           S | S )zGiven a string or unicode instance, produce a new URL instance.

    The given string is parsed according to the RFC 1738 spec.  If an
    existing URL object is passed, just returns the object.
    )r<   r   string_types_parse_rfc1738_args)name_or_urls    r   make_urlry      s-     +t011 ";///r   c                    t          j        dt           j                  }|                    |           }|y|                                }|d         |d                             dd          }|d         |d<   t          |          dk    ri }t          j        |d                   D ]h\  }}t          j	        r|
                    d          }||v r9t          j        ||                   ||<   ||                             |           c|||<   ind }nd }||d<   |d	         t          |d	                   |d	<   |d
         t          |d
                   |d
<   |                    d          }|                    d          }	|p|	|d<   |                    d          } t          | fi |S t!          j        d| z            )Na  
            (?P<name>[\w\+]+)://
            (?:
                (?P<username>[^:/]*)
                (?::(?P<password>.*))?
            @)?
            (?:
                (?:
                    \[(?P<ipv6host>[^/]+)\] |
                    (?P<ipv4host>[^/:]+)
                )?
                (?::(?P<port>[^/]*))?
            )?
            (?:/(?P<database>.*))?
            r   r   r   r   r   asciir   r   r   ipv4hostipv6hostr   r_   z,Could not parse rfc1738 URL from string '%s')recompileXmatch	groupdictrH   lenr   	parse_qslpy2kencoder#   append_rfc_1738_unquoterg   r   r   ArgumentError)
r_   patternm
componentstokensr   keyvaluer|   r}   s
             r   rw   rw      s   j	 	! G& 	dA}[[]]
j!-
+11#q99F%+AYJz"6{{Q"&.";"; + +JCy 2!jj11e||%)\%*%=%=c
c
))%0000%*c

+ E#
7j!-%6z*7M%N%NJz"j!-%6z*7M%N%NJz">>*-->>*--%1
6~~f%%4&&:&&&:TA
 
 	
r   c                 0    t          j        dd |           S )Nz[:@/]c                 L    dt          |                     d                    z  S )Nz%%%Xr   )ordgroup)r   s    r   <lambda>z!_rfc_1738_quote.<locals>.<lambda>(  s    fs1771::&> r   )r~   subtexts    r   r)   r)   '  s    6(>>EEEr   c                 *    t          j        |           S r   )r   unquoter   s    r   r   r   +  s    <r   c                     t          j        d|           }|G|                    dd          \  } }t          t	          j        |                    }t          | g|R  S d S )Nz(\w+)://(.*)r   r   )r~   r   r   dictr   r   r   )r_   r   argsoptss       r   _parse_keyvalue_argsr   /  s_    
$''A}wwq!}}tDN4(())4$tr   )rr   r~   
interfacesr    r   r   dialectsr   r	   objectr   ry   rw   r)   r   r   rA   r   r   <module>r      s     
			                              @ @ @ @ @& @ @ @F
 
 
:
 :
 :
zF F F      r   