def test_url_update(self): url = Url("http://test:123/toto?map=123#456") url.hostname = "example" assert url.netloc == "example:123" assert url.port == 123 assert url.url() == "http://example:123/toto?map=123#456" url = Url("http://test:123/toto?map=123#456") url.netloc = "example" assert url.hostname == "example" assert url.port is None assert url.url() == "http://example/toto?map=123#456" url = Url("http://test:123/toto?map=123#456") url.netloc = "example:234" assert url.hostname == "example" assert url.port == 234 assert url.url() == "http://example:234/toto?map=123#456" url = Url("http://test:123/toto?map=123#456") url.port = 345 assert url.netloc == "test:345" assert url.hostname == "test" assert url.url() == "http://test:345/toto?map=123#456" url = Url("http://test:123/toto?map=123#456") url.port = None assert url.netloc == "test" assert url.hostname == "test" assert url.url() == "http://test/toto?map=123#456"
def _build_url(self, url: Url) -> Tuple[Url, Dict[str, str], Dict[str, Any]]: hostname = url.hostname host_map = self.config.get("lingua_extractor", {}).get("host_map", {}) if hostname in host_map: map_ = host_map[hostname] if "netloc" in map_: url.netloc = map_["netloc"] if "scheme" in map_: url.scheme = map_["scheme"] kwargs = {"verify": map_["verify"]} if "verify" in map_ else {} return url, map_.get("headers", {}), kwargs return url, {}, {}