(netloc: str)
| 43 | |
| 44 | |
| 45 | def split_dsn_netloc(netloc: str) -> tuple[str | None, str | None, str | None, str | None]: |
| 46 | username = None |
| 47 | password = None |
| 48 | host_port = netloc |
| 49 | |
| 50 | if '@' in host_port: |
| 51 | user_info, host_port = host_port.rsplit('@', 1) |
| 52 | username, separator, password = user_info.partition(':') |
| 53 | if not separator: |
| 54 | password = None |
| 55 | |
| 56 | if not host_port: |
| 57 | return username, password, None, None |
| 58 | |
| 59 | if host_port.startswith('['): |
| 60 | end = host_port.find(']') |
| 61 | if end >= 0: |
| 62 | host = host_port[1:end] |
| 63 | port = host_port[end + 2 :] if host_port[end + 1 : end + 2] == ':' else None |
| 64 | return username, password, host, port |
| 65 | |
| 66 | host, separator, port = host_port.partition(':') |
| 67 | return username, password, host or None, port if separator else None |
| 68 | |
| 69 | |
| 70 | def expand_dsn_alias_env_vars( |
no outgoing calls
no test coverage detected