Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show netrc parsing error once #147

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/unearth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,12 @@ def commonprefix(*m: str) -> str:
return s1


_netrc_warned = False


def get_netrc_auth(url: str) -> tuple[str, str] | None:
"""Get the auth for the given url from the netrc file."""
global _netrc_warned
try:
from netrc import NetrcParseError, netrc
except ImportError:
Expand All @@ -302,7 +306,11 @@ def get_netrc_auth(url: str) -> tuple[str, str] | None:
except FileNotFoundError:
return None
except (NetrcParseError, OSError) as e:
logger.warning("Couldn't parse netrc because of %s: %s", type(e).__name__, e)
if not _netrc_warned:
logger.warning(
"Couldn't parse netrc because of %s: %s", type(e).__name__, e
)
_netrc_warned = True
return None
info = authenticator.authenticators(hostname)

Expand Down