r"""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
(
self, names: Optional[List[str]] = None, **kw: Any
)
| 795 | return dialect_cls |
| 796 | |
| 797 | def translate_connect_args( |
| 798 | self, names: Optional[List[str]] = None, **kw: Any |
| 799 | ) -> Dict[str, Any]: |
| 800 | r"""Translate url attributes into a dictionary of connection arguments. |
| 801 | |
| 802 | Returns attributes of this url (`host`, `database`, `username`, |
| 803 | `password`, `port`) as a plain dictionary. The attribute names are |
| 804 | used as the keys by default. Unset or false attributes are omitted |
| 805 | from the final dictionary. |
| 806 | |
| 807 | :param \**kw: Optional, alternate key names for url attributes. |
| 808 | |
| 809 | :param names: Deprecated. Same purpose as the keyword-based alternate |
| 810 | names, but correlates the name to the original positionally. |
| 811 | """ |
| 812 | |
| 813 | if names is not None: |
| 814 | util.warn_deprecated( |
| 815 | "The `URL.translate_connect_args.name`s parameter is " |
| 816 | "deprecated. Please pass the " |
| 817 | "alternate names as kw arguments.", |
| 818 | "1.4", |
| 819 | ) |
| 820 | |
| 821 | translated = {} |
| 822 | attribute_names = ["host", "database", "username", "password", "port"] |
| 823 | for sname in attribute_names: |
| 824 | if names: |
| 825 | name = names.pop(0) |
| 826 | elif sname in kw: |
| 827 | name = kw[sname] |
| 828 | else: |
| 829 | name = sname |
| 830 | if name is not None and getattr(self, sname, False): |
| 831 | if sname == "password": |
| 832 | translated[name] = str(getattr(self, sname)) |
| 833 | else: |
| 834 | translated[name] = getattr(self, sname) |
| 835 | |
| 836 | return translated |
| 837 | |
| 838 | |
| 839 | def make_url(name_or_url: Union[str, URL]) -> URL: |