MCPcopy Create free account
hub / github.com/conda/constructor / get_final_url

Function get_final_url

constructor/utils.py:196–228  ·  view source on GitHub ↗
(info, url)

Source from the content-addressed store, hash-verified

194
195
196def get_final_url(info, url):
197 mapping = info.get("channels_remap", [])
198 if not url.lower().endswith((".tar.bz2", ".conda", "/")):
199 url += "/"
200 added_slash = True
201 else:
202 added_slash = False
203 for entry in mapping:
204 src = entry["src"]
205 dst = entry["dest"]
206 # Treat http:// and https:// as equivalent
207 if src.startswith("http"):
208 srcs = tuple(
209 dict.fromkeys(
210 [src.replace("http://", "https://"), src.replace("https://", "http://")]
211 )
212 )
213 else:
214 srcs = (src,)
215 if url.startswith(srcs):
216 new_url = url
217 for src in srcs:
218 new_url = new_url.replace(src, dst)
219 if url.endswith(".tar.bz2"):
220 logger.warning(
221 "You need to make the package %s available at %s",
222 url.rsplit("/", 1)[1],
223 new_url,
224 )
225 if added_slash:
226 new_url = new_url[:-1]
227 return new_url
228 return url
229
230
231def get_final_channels(info):

Callers 3

get_final_channelsFunction · 0.85
write_filesFunction · 0.85
write_repodata_recordFunction · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected