def _oauth10a_signature(consumer_token, method, url, parameters={}, token=None):
parts = urlparse.urlparse(url)<EOL>scheme, netloc, path = parts[:<NUM_LIT:3>]<EOL>normalized_url = scheme.lower() + "<STR_LIT>" + netloc.lower() + path<EOL>base_elems = []<EOL>base_elems.append(method.upper())<EOL>base_elems.append(normalized_url)<EOL>base_elems.append("<STR_LIT:&>".join("<STR_LIT>" % (k, _oauth_escape(str(v)))<EOL>for k, v in sorted(parameters.items())))<EOL>base_string =  "<STR_LIT:&>".join(_oauth_escape(e) for e in base_elems)<EOL>key_elems = [urllib.quote(consumer_token["<STR_LIT>"], safe='<STR_LIT>')]<EOL>key_elems.append(urllib.quote(token["<STR_LIT>"], safe='<STR_LIT>') if token else "<STR_LIT>")<EOL>key = "<STR_LIT:&>".join(key_elems)<EOL>hash = hmac.new(key, base_string, hashlib.sha1)<EOL>return binascii.b2a_base64(hash.digest())[:-<NUM_LIT:1>]<EOL>
Calculates the HMAC-SHA1 OAuth 1.0a signature for the given request.

    See http://oauth.net/core/1.0a/#signing_process