def add_proxy_auth(possible_proxy_url, proxy_auth):
    """
    Add a username and password to a proxy URL, if the input value is a proxy URL.

    :param str possible_proxy_url: Proxy URL or ``DIRECT``.
    :param requests.auth.HTTPProxyAuth proxy_auth: Proxy authentication info.
    :returns: Proxy URL with auth info added, or ``DIRECT``.
    :rtype: str
    """
    if possible_proxy_url == 'DIRECT':
        return possible_proxy_url
    parsed = urlparse(possible_proxy_url)
    return '{0}://{1}:{2}@{3}'.format(parsed.scheme, proxy_auth.username, proxy_auth.password, parsed.netloc)
Add a username and password to a proxy URL, if the input value is a proxy URL.

    :param str possible_proxy_url: Proxy URL or ``DIRECT``.
    :param requests.auth.HTTPProxyAuth proxy_auth: Proxy authentication info.
    :returns: Proxy URL with auth info added, or ``DIRECT``.
    :rtype: str