def get_login_password(site_name="github.com",
                       netrc_file="~/.netrc",
                       git_credential_file="~/.git-credentials"):
    """Read a .netrc file and return login/password for LWN."""
    try:
        n = netrc.netrc(os.path.expanduser(netrc_file))
    except OSError:
        pass
    else:
        if site_name in n.hosts:
            return n.hosts[site_name][0], n.hosts[site_name][2]

    try:
        with open(os.path.expanduser(git_credential_file)) as f:
            for line in f:
                parsed = parse.urlparse(line.strip())
                if parsed.hostname == site_name:
                    return (parse.unquote(parsed.username),
                            parse.unquote(parsed.password))
    except OSError:
        pass

    return None, None
Read a .netrc file and return login/password for LWN.