-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Add
pex_set_default_index_url()
function and lookup defaul…
…t index URL (#220) * feature: Add `pex_set_default_index_url()` function * fmt * lookup python package index from project settings * fix mypy
- Loading branch information
1 parent
8219c33
commit 605c4c7
Showing
4 changed files
with
71 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[[entries]] | ||
id = "670a651f-b0d2-4d1a-881e-94a70c885749" | ||
type = "feature" | ||
description = "Add `pex_set_default_index_url()` function" | ||
author = "[email protected]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from urllib.parse import urlparse | ||
|
||
|
||
def redact_url_password(url: str, placeholder: str = "[REDACTED]") -> str: | ||
"""Redacts the password in a URL with the given placeholder, if any.""" | ||
|
||
parsed = urlparse(url) | ||
if parsed.password: | ||
replaced = parsed._replace(netloc=f"{parsed.username}:{placeholder}@{parsed.hostname}") | ||
return replaced.geturl() | ||
|
||
|
||
def inject_url_credentials(url: str, username: str, password: str) -> str: | ||
"""Injects a username and password into a URL.""" | ||
|
||
parsed = urlparse(url) | ||
replaced = parsed._replace(netloc=f"{username}:{password}@{parsed.hostname}") | ||
return replaced.geturl() |