def _get_normalized_parameters(parameters, query):
    """Return a string that contains the parameters that must be signed."""
    items = []
    for key, value in parameters.iteritems():
        if key == 'oauth_signature':
            continue
        # 1.0a/9.1.1 states that kvp must be sorted by key, then by value,
        # so we unpack sequence values into multiple items for sorting.
        if isinstance(value, basestring):
            items.append((_to_utf8(key), _to_utf8(value)))
        else:
            try:
                value = list(value)
            except __HOLE__, e:
                assert 'is not iterable' in str(e)
                items.append((_to_utf8(key), _to_utf8(value)))
            else:
                items.extend((_to_utf8(key), _to_utf8(item)) for item in value)

    url_items = _split_url_string(query).items()
    url_items = [(_to_utf8(k), _to_utf8(v))
        for k, v in url_items if k != 'oauth_signature']
    items.extend(url_items)
    items.sort()
    encoded_str = urllib.urlencode(items)
    # Encode signature parameters per Oauth Core 1.0 protocol
    # spec draft 7, section 3.6
    # (http://tools.ietf.org/html/draft-hammer-oauth-07#section-3.6)
    # Spaces must be encoded with "%20" instead of "+"
    return encoded_str.replace('+', '%20').replace('%7E', '~')
dataset/ETHPy150Open moraes/tipfy/tipfy/auth/oauth.py/_get_normalized_parameters