Skip to content

Commit

Permalink
fix: show netrc parsing error once (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming committed Sep 2, 2024
1 parent e4b6386 commit be967a2
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit be967a2

Please sign in to comment.