parses a proxy configuration with known server Args: proxy: The proxy configuration to parse. Returns: A 'playwright' compliant proxy configuration.
(proxy: ProxySettings)
| 132 | |
| 133 | |
| 134 | def _parse_proxy(proxy: ProxySettings) -> ProxySettings: |
| 135 | """parses a proxy configuration with known server |
| 136 | |
| 137 | Args: |
| 138 | proxy: The proxy configuration to parse. |
| 139 | |
| 140 | Returns: |
| 141 | A 'playwright' compliant proxy configuration. |
| 142 | """ |
| 143 | assert "server" in proxy, "missing server in the proxy configuration" |
| 144 | |
| 145 | auhtorization = [x in proxy for x in ("username", "password")] |
| 146 | |
| 147 | message = "username and password must be provided in pairs or not at all" |
| 148 | |
| 149 | assert all(auhtorization) or not any(auhtorization), message |
| 150 | |
| 151 | parsed = {"server": proxy["server"]} |
| 152 | |
| 153 | if proxy.get("bypass"): |
| 154 | parsed["bypass"] = proxy["bypass"] |
| 155 | |
| 156 | if all(auhtorization): |
| 157 | parsed["username"] = proxy["username"] |
| 158 | parsed["password"] = proxy["password"] |
| 159 | |
| 160 | return parsed |
| 161 | |
| 162 | |
| 163 | def _search_proxy(proxy: Proxy) -> ProxySettings: |