(info, url)
| 194 | |
| 195 | |
| 196 | def 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 | |
| 231 | def get_final_channels(info): |
no test coverage detected