diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2022-08-30 09:29:19 -0500 |
---|---|---|
committer | Artem Bityutskiy <dedekind1@gmail.com> | 2022-09-07 09:14:07 +0300 |
commit | be06475d724336deb7fefe002c67371b9f9f907b (patch) | |
tree | bab568b4a27f7bd6869fe3e7b8da19d507c9a343 | |
parent | 1aaa103aef542c38be68dbd9ed8775173db5e206 (diff) |
Add .netrc support
Adds support for getting the username and password from ~/.netrc if it's
not specified in the URL.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
-rw-r--r-- | bmaptools/TransRead.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/bmaptools/TransRead.py b/bmaptools/TransRead.py index 8509bfd..e162eba 100644 --- a/bmaptools/TransRead.py +++ b/bmaptools/TransRead.py @@ -32,6 +32,7 @@ import sys import logging import threading import subprocess +import netrc from six.moves.urllib import parse as urlparse from bmaptools import BmapHelpers @@ -589,6 +590,12 @@ class TransRead(object): username = parsed_url.username password = parsed_url.password + if not username and not password: + auth = netrc.netrc().authenticators(parsed_url.hostname) + if auth: + username = auth[0] + password = auth[2] + if username and password: # Unfortunately, in order to handle URLs which contain user name # and password (e.g., http://user:password@my.site.org), we need to |