=q ~=dZddlZddlmZddlmZddlmZddlmZdd lm Z Gd d e Z d Z d Z dZdZdZdS)aProvides 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)registryceZdZdZ ddZddZdZdZdZd Z d Z e d Z e j d Z d ZdZdZdZdZgfdZdS)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 ||_nd|_||_|pi|_dSN) drivernameusernamepassword_originalhostintportdatabasequery)selfrrpasswordrrrrs /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/sqlalchemy/engine/url.py__init__z URL.__init__8sS%  !)  D DIIDI  [b Tcjdz}jA|tjz }j|d|rdntjzz }|dz }j!djvr|djzz }n |jz }j|dt jzz }j |djzz }jrOtj}| |dd fd |Dzz }|S) Nz://:z***@z[%s]/?&c3K|]Q}tjj|D]/}tj|dtj|V0RdS)=N)rto_listr quote_plus).0kelementrs r z$URL.__to_string__..bs  #|DJqM::   ?1----tw/G/G/GH       r) rr_rfc_1738_quoterrrstrrrlistsortjoin)r hide_passwordskeyss` r __to_string__zURL.__to_string__MsD Oe # = $ // /A}(S*NEE 0N0N HA 9 diVdi''TY 9 s49~~% %A = $ t}$ $A :  ##D IIKKK sxx        A rc.|dS)NF)r.r1rs r__str__z URL.__str__is!!!666rc*|Sr r3r4s r__repr__z URL.__repr__ls!!###rc:tt|Sr )hashr*r4s r__hash__z URL.__hash__osCIIrc t|too|j|jko_|j|jkoO|j|jko?|j|jko/|j|jko|j|jko|j|jkSr ) isinstancer rrrrrrrrothers r__eq__z URL.__eq__rs uc " " (5#33 ( / ( / ( UZ'  (  /  (  ek)  ( UZ' rc||k Sr r=s r__ne__z URL.__ne__~s5=  rcF|jdStj|jSr )rr text_typer4s rrz URL.passwords#  ! )4>$"899 9rc||_dSr )r)rrs rrz URL.passwords!)rcbd|jvr|jS|jddS)N+r)rsplitr4s rget_backend_namezURL.get_backend_names2 do % %? "?((--a0 0rcd|jvr|jS|jddS)NrGr)r get_dialectdriverrHr4s rget_driver_namezURL.get_driver_names? do % %##%%, ,?((--a0 0rctjjdd}|dgz }fd|DS)NpluginrArcLg|] }tj|!SrA)rload)r% plugin_namekwargsrs r z,URL._instantiate_plugins..s?    &GL % %dF 3 3   r)rr#rget)rrS plugin_namess`` r_instantiate_pluginszURL._instantiate_pluginssk|DJNN8R$@$@AA  9b111      +    rcd|jvr|j}n|jdd}tj|}t |dr;t |jtr!t|jtr|jS|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) rreplacer rQhasattrr<rZtype issubclassr)rnameclss r_get_entrypointzURL._get_entrypoints do % %?DD?**344DmD!! C # # 3;-- 3;00  ; JrcX|}||}|S)zfReturn the SQLAlchemy database dialect class corresponding to this URL's driver name. )raget_dialect_cls)r entrypoint dialect_clss rrKzURL.get_dialects.))++  0066 rc i}gd}|D]O}|r|d}n||vr ||}n|}|$t||drt||||<P|S)a2Translate 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. )rrrrrrNF)popgetattr)rnameskw translatedattribute_namessnamer_s rtranslate_connect_argszURL.translate_connect_argss NNN$ 8 8E yy||"%yGD%$?$?#*4#7#7 4 r)NNNNNN)T)__name__ __module__ __qualname____doc__rr1r5r7r:r?rBpropertyrsetterrIrMrWrarKrnrArrr r sB@  !!!!*8777$$$    !!!::X: _**_*111 111    0,.rr cXt|tjrt|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 rmake_urlrys-+t011";///rctjdtj}||}|y|}|d|ddd}|d|d<t |dkri}tj|dD]h\}}tj r| d}||vr9tj ||||<|| |c|||<ind}nd}||d<|d t|d |d <|d t|d |d <|d }|d } |p| |d <|d}t|fi|St!jd|z)Na (?P[\w\+]+):// (?: (?P[^:/]*) (?::(?P.*))? @)? (?: (?: \[(?P[^/]+)\] | (?P[^/:]+) )? (?::(?P[^/]*))? )? (?:/(?P.*))? rrrrrasciirrripv4hostipv6hostrr_z,Could not parse rfc1738 URL from string '%s')recompileXmatch groupdictrHlenr parse_qslpy2kencoder#append_rfc_1738_unquotergr r ArgumentError) r_patternm componentstokensrkeyvaluer|r}s rrwrwsj  !G&  dA}[[]] j ! - +11#q99F%+AYJz "6{{Q"&.";";++JCy2!jj11e||%)\%*%=%=c c ))%0000%*c +E# 7 j ! -%6z*7M%N%NJz " j ! -%6z*7M%N%NJz ">>*-->>*--%1 6~~f%%4&&:&&& :T A   rc0tjdd|S)Nz[:@/]cLdt|dzS)Nz%%%Xr)ordgroup)rs rz!_rfc_1738_quote..(sfs1771::&>r)r~subtexts rr)r)'s 6(>> E EErc*tj|Sr )runquoters rrr+s <  rctjd|}|G|dd\}}tt j|}t |g|RSdS)Nz (\w+)://(.*)rr)r~rrdictrrr )r_rargsoptss r_parse_keyvalue_argsr/s_ $''A}wwq!}} tDN4(())4$tr)rrr~ interfacesrrrdialectsrr objectr ryrwr)rrrArrrs @@@@@&@@@F   : : : zFFFr