zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
U
¸ý°dzã@shdZddlmZddlmZddlZddlmZddlm    Z    ddlm
Z
ddlm Z ddlm Z dd    lm Z dd
lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z Gdd„deƒZ!dddœdd „Z"d!dd"œd#d$„Z#d!d!d%œd&d'„Z$eZ%dS)(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()``.
é)Ú annotationsN)ÚAny)Úcast)ÚDict)ÚIterable)ÚList)ÚMapping)Ú
NamedTuple)ÚOptional)Úoverload)ÚSequence)ÚTuple)ÚType)ÚUnion)Ú    parse_qsl)Ú
quote_plus)Úunquoteé)ÚDialecté)Úexc)Úutil)Úplugins)Úregistryc @sDeZdZUdZded<ded<ded<ded<ded    <ded
<d ed <ed d d d d ejfdddddddddœdd„ƒZedddœdd„ƒZ    eddddœdd„ƒZ
eddddœdd„ƒZ edd dœdd„ƒZ dedddddddddœdd „Z d!dd"œd#d$„Zdfdd&dd'œd(d)„Zdgd*d&dd+œd,d-„Zdhd.d&dd/œd0d1„Zd2dd3œd4d5„Zed6d7œd8d9„ƒZe d:d;¡did&dd=œd>d?„ƒZdjd&dd=œd@dA„Zdd7œdBdC„Zdd7œdDdE„Zd!ddFœdGdH„ZdId7œdJdK„Zd!d&dLœdMdN„Zd!d&dLœdOdP„Zdd7œdQdR„Zdd7œdSdT„ZdUdVdWœdXdY„Z dZd7œd[d\„Z!dkd&dZd]œd^d_„Z"dld`d!dadbœdcdd„Z#d S)mÚURLa 
    Represent the components of a URL used to connect to a database.
 
    URLs are typically constructed from a fully formatted URL string, where the
    :func:`.make_url` function is used internally by the
    :func:`_sa.create_engine` function in order to parse the URL string into
    its individual components, which are then used to construct a new
    :class:`.URL` object. When parsing from a formatted URL string, the parsing
    format generally follows
    `RFC-1738 <https://www.ietf.org/rfc/rfc1738.txt>`_, with some exceptions.
 
    A :class:`_engine.URL` object may also be produced directly, either by
    using the :func:`.make_url` function with a fully formed URL string, or
    by using the :meth:`_engine.URL.create` constructor in order
    to construct a :class:`_engine.URL` programmatically given individual
    fields. The resulting :class:`.URL` object may be passed directly to
    :func:`_sa.create_engine` in place of a string argument, which will bypass
    the usage of :func:`.make_url` within the engine's creation process.
 
    .. versionchanged:: 1.4
 
        The :class:`_engine.URL` object is now an immutable object.  To
        create a URL, use the :func:`_engine.make_url` or
        :meth:`_engine.URL.create` function / method.  To modify
        a :class:`_engine.URL`, use methods like
        :meth:`_engine.URL.set` and
        :meth:`_engine.URL.update_query_dict` to return a new
        :class:`_engine.URL` object with modifications.   See notes for this
        change at :ref:`change_5526`.
 
    .. seealso::
 
        :ref:`database_urls`
 
    :class:`_engine.URL` contains the following attributes:
 
    * :attr:`_engine.URL.drivername`: database backend and driver name, such as
      ``postgresql+psycopg2``
    * :attr:`_engine.URL.username`: username string
    * :attr:`_engine.URL.password`: password string
    * :attr:`_engine.URL.host`: string hostname
    * :attr:`_engine.URL.port`: integer port number
    * :attr:`_engine.URL.database`: string database name
    * :attr:`_engine.URL.query`: an immutable mapping representing the query
      string.  contains strings for keys and either strings or tuples of
      strings for values.
 
 
    ÚstrÚ
drivernamez Optional[str]ÚusernameÚpasswordÚhostz Optional[int]ÚportÚdatabasez4util.immutabledict[str, Union[Tuple[str, ...], str]]ÚqueryNz'Mapping[str, Union[Sequence[str], str]])rrrrr r!r"Úreturnc
Cs@|| |d¡| |d¡|| |d¡| |¡| |d¡| |¡ƒS)aàCreate a new :class:`_engine.URL` object.
 
        .. seealso::
 
            :ref:`database_urls`
 
        :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.  Is typically a string, but may
          also be an object that can be stringified with ``str()``.
 
          .. note::  A password-producing object will be stringified only
             **once** per :class:`_engine.Engine` object.  For dynamic password
             generation per connect, see :ref:`engines_dynamic_tokens`.
 
        :param host: The name of the host.
        :param port: The port number.
        :param database: The database name.
        :param query: A dictionary of string keys to string values to be passed
          to the dialect and/or the DBAPI upon connect.   To specify non-string
          parameters to a Python DBAPI directly, use the
          :paramref:`_sa.create_engine.connect_args` parameter to
          :func:`_sa.create_engine`.   See also
          :attr:`_engine.URL.normalized_query` for a dictionary that is
          consistently string->list of string.
        :return: new :class:`_engine.URL` object.
 
        .. versionadded:: 1.4
 
            The :class:`_engine.URL` object is now an **immutable named
            tuple**.  In addition, the ``query`` dictionary is also immutable.
            To create a URL, use the :func:`_engine.url.make_url` or
            :meth:`_engine.URL.create` function/ method.  To modify a
            :class:`_engine.URL`, use the :meth:`_engine.URL.set` and
            :meth:`_engine.URL.update_query` methods.
 
        rrrr!)Ú _assert_strÚ_assert_none_strÚ _assert_portÚ    _str_dict)Úclsrrrrr r!r"©r)úLd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/engine/url.pyÚcreate•s3
 
 
 
ùz
URL.create)r r#cCs8|dkr dSz
t|ƒWStk
r2tdƒ‚YnXdS)Nz(Port argument must be an integer or None)ÚintÚ    TypeError)r(r r)r)r*r&Òs 
zURL._assert_port)ÚvÚ    paramnamer#cCst|tƒstd|ƒ‚|S)Nz%s must be a string©Ú
isinstancerr-©r(r.r/r)r)r*r$Ûs
 zURL._assert_strcCs|dkr |S| ||¡S©N)r$r2r)r)r*r%ászURL._assert_none_strziOptional[Union[Sequence[Tuple[str, Union[Sequence[str], str]]], Mapping[str, Union[Sequence[str], str]]]])Údict_r#csŽ|dkrtjStdddœdd„ƒ‰tdddœdd„ƒ‰dddœ‡fd    d„ ‰ddd
œd d „‰t|tjƒrl|}n| ¡}t ‡‡fd d„|Dƒ¡S)Nr)Úvalr#cSsdSr3r)©r5r)r)r*Ú _assert_value÷sz$URL._str_dict.<locals>._assert_valuez Sequence[str]zUnion[str, Tuple[str, ...]]cSsdSr3r)r6r)r)r*r7ýszUnion[str, Sequence[str]]cs<t|tƒr|St|tjƒr0t‡fdd„|DƒƒStdƒ‚dS)Nc3s|]}ˆ|ƒVqdSr3r))Ú.0Úelem©r7r)r*Ú    <genexpr>    sz7URL._str_dict.<locals>._assert_value.<locals>.<genexpr>z?Query dictionary values must be strings or sequences of strings)r1rÚcollections_abcr Útupler-r6r:r)r*r7s
 ÿ)r.r#cSst|tƒstdƒ‚|S)Nz%Query dictionary keys must be stringsr0)r.r)r)r*r$s
z"URL._str_dict.<locals>._assert_strcsi|]\}}ˆ|ƒˆ|ƒ“qSr)r))r8ÚkeyÚvalue©r$r7r)r*Ú
<dictcomp>s
ýÿz!URL._str_dict.<locals>.<dictcomp>)rÚ
EMPTY_DICTr r1r<r ÚitemsÚ immutabledict)r(r4Ú
dict_itemsr)r@r*r'ês 
   üÿz URL._str_dictz1Optional[Mapping[str, Union[Sequence[str], str]]]c    Cs€i}|dk    r||d<|dk    r$||d<|dk    r4||d<|dk    rD||d<|dk    rT||d<|dk    rd||d<|dk    rt||d<|jf|ŽS)    areturn a new :class:`_engine.URL` object with modifications.
 
        Values are used if they are non-None.  To set a value to ``None``
        explicitly, use the :meth:`_engine.URL._replace` method adapted
        from ``namedtuple``.
 
        :param drivername: new drivername
        :param username: new username
        :param password: new password
        :param host: new hostname
        :param port: new port
        :param query: new query parameters, passed a dict of string keys
         referring to string or sequence of string values.  Fully
         replaces the previous list of arguments.
 
        :return: new :class:`_engine.URL` object.
 
        .. versionadded:: 1.4
 
        .. seealso::
 
            :meth:`_engine.URL.update_query_dict`
 
        Nrrrrr r!r")Ú_assert_replace)    Úselfrrrrr r!r"Úkwr)r)r*Úset$s #zURL.setr)rHr#cKsvd|kr| |dd¡dD]}||kr| |||¡qd|krP| |d¡d|krj| |d¡|d<|jf|ŽS)z)argument checks before calling _replace()r)rrr!r r")r$r%r&r'Ú_replace)rGrHÚnamer)r)r*rFYszURL._assert_replaceFÚbool)Ú query_stringÚappendr#cCs|jt|ƒ|dS)aEReturn a new :class:`_engine.URL` object with the :attr:`_engine.URL.query`
        parameter dictionary updated by the given query string.
 
        E.g.::
 
            >>> from sqlalchemy.engine import make_url
            >>> url = make_url("postgresql+psycopg2://user:pass@host/dbname")
            >>> url = url.update_query_string("alt_host=host1&alt_host=host2&ssl_cipher=%2Fpath%2Fto%2Fcrt")
            >>> str(url)
            'postgresql+psycopg2://user:pass@host/dbname?alt_host=host1&alt_host=host2&ssl_cipher=%2Fpath%2Fto%2Fcrt'
 
        :param query_string: a URL escaped query string, not including the
         question mark.
 
        :param append: if True, parameters in the existing query string will
         not be removed; new parameters will be in addition to those present.
         If left at its default of False, keys present in the given query
         parameters will replace those of the existing query string.
 
        .. versionadded:: 1.4
 
        .. seealso::
 
            :attr:`_engine.URL.query`
 
            :meth:`_engine.URL.update_query_dict`
 
        ©rN)Úupdate_query_pairsr)rGrMrNr)r)r*Úupdate_query_stringhszURL.update_query_stringz+Iterable[Tuple[str, Union[str, List[str]]]])Úkey_value_pairsrNr#cs|j‰i}|D]\\}}||krLt ||¡||<td||ƒ tt|ƒ¡qt|ttfƒrbt|ƒn|||<q|rÜi}|D]>}|ˆkrªtt ˆ|¡t ||¡ƒ||<qx||||<qx|     ‡fdd„t
ˆƒ  |¡Dƒ¡n|j  dd„|  ¡Dƒ¡}|j
|dS)aŽReturn a new :class:`_engine.URL` object with the
        :attr:`_engine.URL.query`
        parameter dictionary updated by the given sequence of key/value pairs
 
        E.g.::
 
            >>> from sqlalchemy.engine import make_url
            >>> url = make_url("postgresql+psycopg2://user:pass@host/dbname")
            >>> url = url.update_query_pairs([("alt_host", "host1"), ("alt_host", "host2"), ("ssl_cipher", "/path/to/crt")])
            >>> str(url)
            'postgresql+psycopg2://user:pass@host/dbname?alt_host=host1&alt_host=host2&ssl_cipher=%2Fpath%2Fto%2Fcrt'
 
        :param key_value_pairs: A sequence of tuples containing two strings
         each.
 
        :param append: if True, parameters in the existing query string will
         not be removed; new parameters will be in addition to those present.
         If left at its default of False, keys present in the given query
         parameters will replace those of the existing query string.
 
        .. versionadded:: 1.4
 
        .. seealso::
 
            :attr:`_engine.URL.query`
 
            :meth:`_engine.URL.difference_update_query`
 
            :meth:`_engine.URL.set`
 
        ú    List[str]csi|]}|ˆ|“qSr)r))r8Úk©Zexisting_queryr)r*rAÈsÿz*URL.update_query_pairs.<locals>.<dictcomp>cSs(i|] \}}|t|tƒr t|ƒn|“qSr))r1Úlistr=©r8rTr.r)r)r*rAÏsÿ©r")r"rÚto_listrrNrr1rVr=ÚupdaterIÚ
differenceÚunionrC)rGrRrNZnew_keysr>r?Z    new_queryrTr)rUr*rP‰s:% ÿ  ÿÿ
 
 þÿþÿzURL.update_query_pairsz#Mapping[str, Union[str, List[str]]])Úquery_parametersrNr#cCs|j| ¡|dS)aÉReturn a new :class:`_engine.URL` object with the
        :attr:`_engine.URL.query` parameter dictionary updated by the given
        dictionary.
 
        The dictionary typically contains string keys and string values.
        In order to represent a query parameter that is expressed multiple
        times, pass a sequence of string values.
 
        E.g.::
 
 
            >>> from sqlalchemy.engine import make_url
            >>> url = make_url("postgresql+psycopg2://user:pass@host/dbname")
            >>> url = url.update_query_dict({"alt_host": ["host1", "host2"], "ssl_cipher": "/path/to/crt"})
            >>> str(url)
            'postgresql+psycopg2://user:pass@host/dbname?alt_host=host1&alt_host=host2&ssl_cipher=%2Fpath%2Fto%2Fcrt'
 
 
        :param query_parameters: A dictionary with string keys and values
         that are either strings, or sequences of strings.
 
        :param append: if True, parameters in the existing query string will
         not be removed; new parameters will be in addition to those present.
         If left at its default of False, keys present in the given query
         parameters will replace those of the existing query string.
 
 
        .. versionadded:: 1.4
 
        .. seealso::
 
            :attr:`_engine.URL.query`
 
            :meth:`_engine.URL.update_query_string`
 
            :meth:`_engine.URL.update_query_pairs`
 
            :meth:`_engine.URL.difference_update_query`
 
            :meth:`_engine.URL.set`
 
        rO)rPrC)rGr]rNr)r)r*Úupdate_query_dictÖs/zURL.update_query_dictz Iterable[str])Únamesr#c sTt|ƒ ˆj¡sˆStˆjˆjˆjˆjˆjˆj    t
  ‡fdd„tˆjƒ  |¡Dƒ¡ƒS)a’
        Remove the given names from the :attr:`_engine.URL.query` dictionary,
        returning the new :class:`_engine.URL`.
 
        E.g.::
 
            url = url.difference_update_query(['foo', 'bar'])
 
        Equivalent to using :meth:`_engine.URL.set` as follows::
 
            url = url.set(
                query={
                    key: url.query[key]
                    for key in set(url.query).difference(['foo', 'bar'])
                }
            )
 
        .. versionadded:: 1.4
 
        .. seealso::
 
            :attr:`_engine.URL.query`
 
            :meth:`_engine.URL.update_query_dict`
 
            :meth:`_engine.URL.set`
 
        csi|]}|ˆj|“qSr)rX)r8r>©rGr)r*rA0sÿz/URL.difference_update_query.<locals>.<dictcomp>) rIÚ intersectionr"rrrrrr r!rrDr[)rGr_r)r`r*Údifference_update_querys
þÿùzURL.difference_update_queryzMapping[str, Sequence[str]])r#cCst dd„|j ¡Dƒ¡S)aReturn the :attr:`_engine.URL.query` dictionary with values normalized
        into sequences.
 
        As the :attr:`_engine.URL.query` dictionary may contain either
        string values or sequences of string values to differentiate between
        parameters that are specified multiple times in the query string,
        code that needs to handle multiple parameters generically will wish
        to use this attribute so that all parameters present are presented
        as sequences.   Inspiration is from Python's ``urllib.parse.parse_qs``
        function.  E.g.::
 
 
            >>> from sqlalchemy.engine import make_url
            >>> url = make_url("postgresql+psycopg2://user:pass@host/dbname?alt_host=host1&alt_host=host2&ssl_cipher=%2Fpath%2Fto%2Fcrt")
            >>> url.query
            immutabledict({'alt_host': ('host1', 'host2'), 'ssl_cipher': '/path/to/crt'})
            >>> url.normalized_query
            immutabledict({'alt_host': ('host1', 'host2'), 'ssl_cipher': ('/path/to/crt',)})
 
        cSs&i|]\}}|t|tƒs|fn|“qSr))r1r=rWr)r)r*rAOsÿz(URL.normalized_query.<locals>.<dictcomp>)rrDr"rCr`r)r)r*Únormalized_query7s
þÿzURL.normalized_queryú1.4zŸThe :meth:`_engine.URL.__to_string__ method is deprecated and will be removed in a future release.  Please use the :meth:`_engine.URL.render_as_string` method.T)Ú hide_passwordr#cCs |j|dS)z¿Render this :class:`_engine.URL` object as a string.
 
        :param hide_password: Defaults to True.   The password is not shown
         in the string unless this is set to False.
 
        )re©Úrender_as_string)rGrer)r)r*Ú __to_string__Us zURL.__to_string__csðˆjd}ˆjdk    rR|tˆjƒ7}ˆjdk    rJ|d|r8dn ttˆjƒƒ7}|d7}ˆjdk    r€dˆjkrv|dˆj7}n
|ˆj7}ˆjdk    rœ|dtˆjƒ7}ˆjdk    r´|dˆj7}ˆjrìt    ˆjƒ}| 
¡|dd      ‡fd
d „|Dƒ¡7}|S) aRRender this :class:`_engine.URL` object as a string.
 
        This method is used when the ``__str__()`` or ``__repr__()``
        methods are used.   The method directly includes additional options.
 
        :param hide_password: Defaults to True.   The password is not shown
         in the string unless this is set to False.
 
        z://Nú:z***ú@z[%s]ú/ú?ú&c3s8|]0}t ˆj|¡D]}dt|ƒt|ƒfVqqdS)z%s=%sN)rrYr"r)r8rTÚelementr`r)r*r;„sþz'URL.render_as_string.<locals>.<genexpr>) rrÚ_sqla_url_quoterrrr r!r"rVÚsortÚjoin)rGreÚsÚkeysr)r`r*rgds2
 
 
 
ÿ ý
 
 
 
 
 
þ zURL.render_as_stringcCs| ¡Sr3rfr`r)r)r*Ú__repr__‹sz URL.__repr__c    Cs&|j |j|j|j|j|j|j|j¡Sr3)    Ú    __class__r+rrrrr r!r"r`r)r)r*Ú__copy__Žs÷z URL.__copy__)Úmemor#cCs| ¡Sr3)rv)rGrwr)r)r*Ú __deepcopy__›szURL.__deepcopy__r,cCs tt|ƒƒSr3)Úhashrr`r)r)r*Ú__hash__žsz URL.__hash__)Úotherr#cCs^t|tƒo\|j|jko\|j|jko\|j|jko\|j|jko\|j|jko\|j|jko\|j|jkSr3)    r1rrrrrr!r"r ©rGr{r)r)r*Ú__eq__¡s
 
ÿ
þ
ý
ü
û
ú
øz
URL.__eq__cCs
||k Sr3r)r|r)r)r*Ú__ne__­sz
URL.__ne__cCs$d|jkr|jS|j d¡dSdS)zÜReturn the backend name.
 
        This is the name that corresponds to the database backend in
        use, and is the portion of the :attr:`_engine.URL.drivername`
        that is to the left of the plus sign.
 
        ú+rN)rÚsplitr`r)r)r*Úget_backend_name°s
zURL.get_backend_namecCs(d|jkr| ¡jS|j d¡dSdS)a«Return the backend name.
 
        This is the name that corresponds to the DBAPI driver in
        use, and is the portion of the :attr:`_engine.URL.drivername`
        that is to the right of the plus sign.
 
        If the :attr:`_engine.URL.drivername` does not include a plus sign,
        then the default :class:`_engine.Dialect` for this :class:`_engine.URL`
        is imported in order to get the driver name.
 
        rrN)rÚ get_dialectZdriverr€r`r)r)r*Úget_driver_name½s
 
zURL.get_driver_namezMapping[str, Any]z%Tuple[URL, List[Any], Dict[str, Any]])Úkwargsr#cs„t ˆj dd¡¡}|ˆ dg¡7}tˆƒ‰‡‡fdd„|Dƒ}ˆ ddg¡}|D]}| |¡}|dk    rR|}qRˆ dd¡||ˆfS)NÚpluginr)rcsg|]}t |¡ˆˆƒ‘qSr))rÚload)r8Z plugin_name©r„rGr)r*Ú
<listcomp>×sÿz,URL._instantiate_plugins.<locals>.<listcomp>)rrYr"ÚgetÚdictrbZ
update_urlÚpop)rGr„Z plugin_namesZloaded_pluginsÚur…Znew_ur)r‡r*Ú_instantiate_pluginsÏs þ
 zURL._instantiate_pluginsú Type[Dialect]cCs`d|jkr|j}n|j dd¡}t |¡}t|dƒrRt|jtƒrRt|jt    ƒrR|jSt
d|ƒSdS)zºReturn 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.
 
        rÚ.ÚdialectrŽN) rÚreplacerr†Úhasattrr1rÚtypeÚ
issubclassrr)rGrKr(r)r)r*Ú_get_entrypointçs
 
ÿ
þ
ýzURL._get_entrypoint)Ú    _is_asyncr#cCs&| ¡}|r| |¡}n
| |¡}|S)zoReturn the SQLAlchemy :class:`_engine.Dialect` class corresponding
        to this URL's driver name.
 
        )r•Zget_async_dialect_clsZget_dialect_cls)rGr–Z
entrypointZ dialect_clsr)r)r*r‚ÿs
 
zURL.get_dialectzOptional[List[str]]zDict[str, Any])r_rHr#cKs˜|dk    rt dd¡i}dddddg}|D]h}|r>| d    ¡}n||krP||}n|}|dk    r*t||d
ƒr*|dkr„tt||ƒƒ||<q*t||ƒ||<q*|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.
        NzpThe `URL.translate_connect_args.name`s parameter is deprecated. Please pass the alternate names as kw arguments.rdrr!rrr rF)rZwarn_deprecatedr‹Úgetattrr)rGr_rHZ
translatedZattribute_namesZsnamerKr)r)r*Útranslate_connect_args s$ü 
zURL.translate_connect_args)NNNNNNN)F)F)F)T)T)F)N)$Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú__annotations__Ú classmethodrrBr+r&r$r%r'rIrFrQrPr^rbÚpropertyrcÚ
deprecatedrhrgrtrvrxrzr}r~rrƒrr•r‚r˜r)r)r)r*r-sz
2ø <;ø5ÿ$ýPý10þ    '    ÿrzUnion[str, URL])Ú name_or_urlr#cCst|tƒrt|ƒS|SdS)a…Given a string, produce a new URL instance.
 
    The format of the URL generally follows `RFC-1738
    <https://www.ietf.org/rfc/rfc1738.txt>`_, with some exceptions, including
    that underscores, and not dashes or periods, are accepted within the
    "scheme" portion.
 
    If a :class:`.URL` object is passed, it is returned as is.
 
    .. seealso::
 
        :ref:`database_urls`
 
    N)r1rÚ
_parse_url)r¡r)r)r*Úmake_url5s
r£r)rKr#c    Cs2t dtj¡}| |¡}|dk    r | ¡}|ddk    rŠi}t|dƒD]@\}}||kr~t ||¡||<td||ƒ     |¡qF|||<qFnd}||d<|ddk    r²t
|dƒ|d<|ddk    rÎt
|dƒ|d<|  d¡}|  d¡}|pè||d<|  d    ¡}|d
rt |d
ƒ|d
<t j|f|ŽSt d |¡‚dS) Na®
            (?P<name>[\w\+]+)://
            (?:
                (?P<username>[^:/]*)
                (?::(?P<password>[^@]*))?
            @)?
            (?:
                (?:
                    \[(?P<ipv6host>[^/\?]+)\] |
                    (?P<ipv4host>[^/:\?]+)
                )?
                (?::(?P<port>[^/\?]*))?
            )?
            (?:/(?P<database>[^\?]*))?
            (?:\?(?P<query>.*))?
            r"rSrrÚipv4hostÚipv6hostrrKr z/Could not parse SQLAlchemy URL from string '%s')ÚreÚcompileÚXÚmatchÚ    groupdictrrrYrrNÚ_sqla_url_unquoter‹r,rr+rÚ ArgumentError)    rKÚpatternÚmÚ
componentsr"r>r?r¤r¥r)r)r*r¢Ks<ï
 
 
 
 
 
ÿr¢)Útextr#cCst ddd„|¡S)Nz[:@/]cSsdt| d¡ƒS)Nz%%%Xr)ÚordÚgroup)r®r)r)r*Ú<lambda>ˆóz!_sqla_url_quote.<locals>.<lambda>)r¦Úsub)r°r)r)r*ro‡sro)&rœÚ
__future__rÚcollections.abcÚabcr<r¦Útypingrrrrrrr    r
r r r rrÚ urllib.parserrrZ
interfacesrÚrrZdialectsrrrr£r¢ror«r)r)r)r*Ú<module>sF                           <