# Path: pyoauth/_compat.py
# def unquote_plus(v):
# 
# Path: pyoauth/constants.py
# SYMBOL_QUESTION_MARK = b("?")
# 
# SYMBOL_AMPERSAND = b("&")
# 
# SYMBOL_EQUAL = b("=")
# 
# OAUTH_PARAM_PREFIX = "oauth_"
# 
# OAUTH_VALUE_CALLBACK_OOB = b("oob")
# 
# OAUTH_PARAM_CONSUMER_SECRET = "oauth_consumer_secret"
# 
# OAUTH_PARAM_TOKEN_SECRET = "oauth_token_secret"
# 
# SYMBOL_EMPTY_BYTES = b("")
# 
# Path: pyoauth/error.py
# class InvalidQueryParametersError(OAuthError):
#     """
#     Raised when a query parameter is invalid.
#     """
#     pass
# 
# class InsecureOAuthParametersError(OAuthError):
#     """
#     Raised when an OAuth confidential parameter is passed into protocol
#     parameters.
#     """
#     pass
# 
# class InvalidOAuthParametersError(OAuthError):
#     """
#     Raised when invalid protocol parameters are detected.
#     """
#     pass
# 
# class InsecureOAuthUrlError(OAuthError):
#     """
#     Raised when an insecure (non-HTTPS) URL is detected for requesting OAuth
#     credentials.
#     """
#     pass
# 
# class InvalidUrlError(OAuthError):
#     """
#     Raised when a specified URL is invalid for consumption by a routine.
#     """
#     pass


import logging
from mom.builtins import is_sequence, bytes, is_bytes_or_unicode, is_bytes
from mom.codec.text import utf8_encode_if_unicode, \
    utf8_encode, utf8_decode_if_bytes
from mom.functional import select_dict, map_dict
from mom.builtins import b
from pyoauth._compat import urlparse, urlunparse, parse_qs as _parse_qs, \
    quote, \
    unquote_plus
from pyoauth.constants import SYMBOL_QUESTION_MARK, \
    SYMBOL_AMPERSAND, SYMBOL_EQUAL, OAUTH_PARAM_PREFIX, \
    OAUTH_VALUE_CALLBACK_OOB, OAUTH_PARAM_CONSUMER_SECRET, \
    OAUTH_PARAM_TOKEN_SECRET, SYMBOL_EMPTY_BYTES
from pyoauth.error import InvalidQueryParametersError, \
    InsecureOAuthParametersError, \
    InvalidOAuthParametersError, \
    InsecureOAuthUrlError, \
    InvalidUrlError
            # Loop over the sequence.
            if len(value) > 0:
                for i in value:
                    encoded_pairs.append((key, percent_encode(i), ))
            # ``urllib.urlencode()`` doesn't preserve blank lists.
            # Therefore, we're discarding them.
            #else:
            #    # Preserve blank list values.
            #    encoded_pairs.append((k, "", ))
        else:
            encoded_pairs.append((key, percent_encode(value),))
    # Sort after encoding according to the OAuth spec.
    return sorted(encoded_pairs)


def urlparse_normalized(url):
    """
    Like :func:`urlparse.urlparse` but also normalizes scheme, netloc, port,
    and the path.

    Use with OAuth URLs.

    :see: Base String URI (http://tools.ietf.org/html/rfc5849#section-3.4.1.2)
    :param url:
        The URL to split and normalize.
    :returns:
        Tuple that contains these elements:
        ``(scheme, netloc, path, params, query, fragment)``
    """
    if not url:

# Path: pyoauth/_compat.py
# def unquote_plus(v):
# 
# Path: pyoauth/constants.py
# SYMBOL_QUESTION_MARK = b("?")
# 
# SYMBOL_AMPERSAND = b("&")
# 
# SYMBOL_EQUAL = b("=")
# 
# OAUTH_PARAM_PREFIX = "oauth_"
# 
# OAUTH_VALUE_CALLBACK_OOB = b("oob")
# 
# OAUTH_PARAM_CONSUMER_SECRET = "oauth_consumer_secret"
# 
# OAUTH_PARAM_TOKEN_SECRET = "oauth_token_secret"
# 
# SYMBOL_EMPTY_BYTES = b("")
# 
# Path: pyoauth/error.py
# class InvalidQueryParametersError(OAuthError):
#     """
#     Raised when a query parameter is invalid.
#     """
#     pass
# 
# class InsecureOAuthParametersError(OAuthError):
#     """
#     Raised when an OAuth confidential parameter is passed into protocol
#     parameters.
#     """
#     pass
# 
# class InvalidOAuthParametersError(OAuthError):
#     """
#     Raised when invalid protocol parameters are detected.
#     """
#     pass
# 
# class InsecureOAuthUrlError(OAuthError):
#     """
#     Raised when an insecure (non-HTTPS) URL is detected for requesting OAuth
#     credentials.
#     """
#     pass
# 
# class InvalidUrlError(OAuthError):
#     """
#     Raised when a specified URL is invalid for consumption by a routine.
#     """
#     pass


# Path: pyoauth/url.py
import logging
from mom.builtins import is_sequence, bytes, is_bytes_or_unicode, is_bytes
from mom.codec.text import utf8_encode_if_unicode, \
    utf8_encode, utf8_decode_if_bytes
from mom.functional import select_dict, map_dict
from mom.builtins import b
from pyoauth._compat import urlparse, urlunparse, parse_qs as _parse_qs, \
    quote, \
    unquote_plus
from pyoauth.constants import SYMBOL_QUESTION_MARK, \
    SYMBOL_AMPERSAND, SYMBOL_EQUAL, OAUTH_PARAM_PREFIX, \
    OAUTH_VALUE_CALLBACK_OOB, OAUTH_PARAM_CONSUMER_SECRET, \
    OAUTH_PARAM_TOKEN_SECRET, SYMBOL_EMPTY_BYTES
from pyoauth.error import InvalidQueryParametersError, \
    InsecureOAuthParametersError, \
    InvalidOAuthParametersError, \
    InsecureOAuthUrlError, \
    InvalidUrlError

            # Loop over the sequence.
            if len(value) > 0:
                for i in value:
                    encoded_pairs.append((key, percent_encode(i), ))
            # ``urllib.urlencode()`` doesn't preserve blank lists.
            # Therefore, we're discarding them.
            #else:
            #    # Preserve blank list values.
            #    encoded_pairs.append((k, "", ))
        else:
            encoded_pairs.append((key, percent_encode(value),))
    # Sort after encoding according to the OAuth spec.
    return sorted(encoded_pairs)


def urlparse_normalized(url):
    """
    Like :func:`urlparse.urlparse` but also normalizes scheme, netloc, port,
    and the path.

    Use with OAuth URLs.

    :see: Base String URI (http://tools.ietf.org/html/rfc5849#section-3.4.1.2)
    :param url:
        The URL to split and normalize.
    :returns:
        Tuple that contains these elements:
        ``(scheme, netloc, path, params, query, fragment)``
    """
    if not url:

        raise InvalidUrlError("Invalid URL `%r`" % (url,))