MCPcopy
hub / github.com/encode/starlette / replace

Method replace

starlette/datastructures.py:115–141  ·  starlette/datastructures.py::URL.replace
(self, **kwargs: Any)

Source from the content-addressed store, hash-verified

113 return self.scheme in (class="st">"https", class="st">"wss")
114
115 def replace(self, **kwargs: Any) -> URL:
116 if class="st">"username" in kwargs or class="st">"password" in kwargs or class="st">"hostname" in kwargs or class="st">"port" in kwargs:
117 hostname = kwargs.pop(class="st">"hostname", None)
118 port = kwargs.pop(class="st">"port", self.port)
119 username = kwargs.pop(class="st">"username", self.username)
120 password = kwargs.pop(class="st">"password", self.password)
121
122 if hostname is None:
123 netloc = self.netloc
124 _, _, hostname = netloc.rpartition(class="st">"@")
125
126 if hostname and hostname[-1] != class="st">"]":
127 hostname = hostname.rsplit(class="st">":", 1)[0]
128
129 netloc = hostname
130 if port is not None:
131 netloc += fclass="st">":{port}"
132 if username is not None:
133 userpass = username
134 if password is not None:
135 userpass += fclass="st">":{password}"
136 netloc = fclass="st">"{userpass}@{netloc}"
137
138 kwargs[class="st">"netloc"] = netloc
139
140 components = self.components._replace(**kwargs)
141 return self.__class__(components.geturl())
142
143 def include_query_params(self, **kwargs: Any) -> URL:
144 params = MultiDict(parse_qsl(self.query, keep_blank_values=True))

Callers 12

get_responseMethod · 0.95
include_query_paramsMethod · 0.95
replace_query_paramsMethod · 0.95
remove_query_paramsMethod · 0.95
__repr__Method · 0.95
__call__Method · 0.95
__call__Method · 0.95
test_urlFunction · 0.95
replace_paramsFunction · 0.80
__init__Method · 0.80
format_lineMethod · 0.80
build_environFunction · 0.80

Calls 1

popMethod · 0.45

Tested by 1

test_urlFunction · 0.76