figure out the signature with some defaults
490947
private function getSignatureMethod($request)
    {
        $signature_method = $request instanceof Request
            ? $request->getParameter("oauth_signature_method")
            : null;

        if (!$signature_method) {
            // According to chapter 7 ("Accessing Protected Ressources") the signature-method
            // parameter is required, and we can't just fallback to PLAINTEXT
            throw new Exception('No signature method parameter. This parameter is required');
        }

        if (!in_array(
            $signature_method,
            array_keys($this->signature_methods)
        )) {
            throw new Exception(
                "Signature method '$signature_method' not supported " .
                "try one of the following: " .
                implode(", ", array_keys($this->signature_methods))
            );
        }
        return $this->signature_methods[$signature_method];
    }
878450
def get_default(__func: Callable, __arg: str) -> str:
    
    return signature(__func).parameters[__arg].default
279267
function parseArgs(signature) {
  var args = [];
  var count = {};
  var index = {};
  var length = signature.length;
  for (var i = 0; i < length; i++) {
    var arg = signature[i];
    if (count[arg]) {
      count[arg]++;
    } else {
      count[arg] = 1;
    }
    index[arg] = 0;
  }
  for (var i = 0; i < length; i++) {
    var arg = signature[i];
    if (count[arg] > 1) {
      args.push(arg + "" + index[arg]);
      index[arg]++;
    } else {
      args.push(arg);
    }
  }
  return args
}
243036
def signature_base_string
      base = [method, normalized_uri, normalized_parameters]
      base.map { |v| escape(v) }.join("&")
    end
579084
def get_key_signature_accidentals(key='C'):
    """"""
    accidentals = get_key_signature(key)
    res = []

    if accidentals < 0:
        for i in range(-accidentals):
            res.append('{0}{1}'.format(list(reversed(notes.fifths))[i], 'b'))
    elif accidentals > 0:
        for i in range(accidentals):
            res.append('{0}{1}'.format(notes.fifths[i], '#'))
    return res
1203267
def default(cls):
    
    if cls._DEFAULT is None:
      cls._DEFAULT = cls.skip_signatures_and_duplicates_concat_well_known_metadata()
    return cls._DEFAULT
513959
def signature(self):
        """"""
        if not use_signature:
            raise NotImplementedError("Python 3 only.")

        if self.static:
            parameters = \
                (Parameter(name='cls',
                           kind=Parameter.POSITIONAL_ONLY),)

        else:
            parameters = \
                (Parameter(name='self',
                           kind=Parameter.POSITIONAL_ONLY),)

        if self.input_transform:
            return signature(self.input_transform)

        if self.uses_request:
            fields = get_fields(self.request_type)
            if not self.static:
                if self.field_name not in fields:
                    raise NameError("field '{}' not found in {}".format(
                        self.field_name, self.request_name))
                fields.remove(self.field_name)
            parameters += tuple(
                Parameter(name=name, kind=Parameter.POSITIONAL_OR_KEYWORD,
                          default=None)
                for name in fields)

        return Signature(parameters)
247779
function signature(m) {
    return m.get(f.signature)
            .orElse(_ => m.get(f.name))
            .getOrElse('(Anonymous)');
  }
635470
def check_signature(signature, key, data):
    """"""
    if isinstance(key, type(u'')):
        key = key.encode()

    digest = 'sha1=' + hmac.new(key, data, hashlib.sha1).hexdigest()

    # Covert everything to byte sequences
    if isinstance(digest, type(u'')):
        digest = digest.encode()
    if isinstance(signature, type(u'')):
        signature = signature.encode()

    return werkzeug.security.safe_str_cmp(digest, signature)
724679
def generate_signature(params, returns, condition=nil)
      params = params.split(//) if params.respond_to?(:split) # Convert params string into array
      params.map! {|param| TYPES[param.to_sym] || param} # Convert chars into FFI type symbols
      returns = TYPES[returns.to_sym] || returns # Convert chars into FFI type symbols
      [params, returns, condition]
    end
867194
def __encoded_params_for_signature(cls, params):
        
        def encoded_pairs(params):
            for k, v in six.iteritems(params):
                if k == 'hmac':
                    continue

                if k.endswith('[]'):
                    #foo[]=1&foo[]=2 has to be transformed as foo=["1", "2"] note the whitespace after comma
                    k = k.rstrip('[]')
                    v = json.dumps(list(map(str, v)))

                # escape delimiters to avoid tampering
                k = str(k).replace("%", "%25").replace("=", "%3D")
                v = str(v).replace("%", "%25")
                yield '{0}={1}'.format(k, v).replace("&", "%26")

        return "&".join(sorted(encoded_pairs(params)))
459666
def get_function_signature(self, node):
        """"""
        name = self.extract_text(self.get_specific_subnodes(node, 'name'))
        if self.with_type_info:
            argsstring = self.extract_text(self.get_specific_subnodes(node, 'argsstring'))
        else:
            argsstring = []
            param_id = 1
            for n_param in self.get_specific_subnodes(node, 'param'):
                declname = self.extract_text(self.get_specific_subnodes(n_param, 'declname'))
                if not declname:
                    declname = 'arg' + str(param_id)
                defval = self.extract_text(self.get_specific_subnodes(n_param, 'defval'))
                if defval:
                    defval = '=' + defval
                argsstring.append(declname + defval)
                param_id = param_id + 1
            argsstring = '(' + ', '.join(argsstring) + ')'
        type = self.extract_text(self.get_specific_subnodes(node, 'type'))
        function_definition = name + argsstring
        if type != '' and type != 'void':
            function_definition = function_definition + ' -> ' + type
        return '`' + function_definition + '`  '
232275
def compute_signature params
      if $DEBUG
        puts "keys before sorted: #{params.keys}"
      end

      sorted_keys = params.keys.sort

      if $DEBUG
        puts "keys after sorted: #{sorted_keys}"
      end

      canonicalized_query_string = ""

      canonicalized_query_string = sorted_keys.map {|key|
        "%s=%s" % [safe_encode(key.to_s), safe_encode(params[key])]
      }.join(self.service.separator)

      length = canonicalized_query_string.length

      string_to_sign = self.service.http_method + self.service.separator + safe_encode('/') + self.service.separator + safe_encode(canonicalized_query_string)

      if $DEBUG
        puts "string_to_sign is #{string_to_sign}"
      end

      signature = calculate_signature access_key_secret+"&", string_to_sign
    end
116638
def _compute_signature(parameters, access_key_secret, method, path):
    '''
    
    '''
    parameters['signature_method'] = 'HmacSHA256'

    string_to_sign = '{0}\n{1}\n'.format(method.upper(), path)

    keys = sorted(parameters.keys())
    pairs = []
    for key in keys:
        val = six.text_type(parameters[key]).encode('utf-8')
        pairs.append(_quote(key, safe='') + '=' + _quote(val, safe='-_~'))
    qs = '&'.join(pairs)
    string_to_sign += qs

    h = hmac.new(access_key_secret, digestmod=sha256)
    h.update(string_to_sign)

    signature = base64.b64encode(h.digest()).strip()

    return signature
662318
function getFunctionSignature(fn) {
  let str = fn.toString()

  // Strip comments.
  str = str.replace(/\/\/[^\r\n]*|\/\*[\s\S]*?\*\//g, '')

  const match = str.match(/\(([^)]*)\)/)

  if (match) {
    let res = match[1]

    // Strip leading and trailing whitespace.
    res = res.replace(/^\s+|\s+$/g, '')

    let sig = res.split(/\s*,\s*/)

    if (sig.length === 1 && !sig[0]) {
      sig.length = 0
    }

    const signature = []

    for (let key of sig) {
      // TODO: Handle rest parameters. The position of the rest
      // parameter matters, so this requires some thought. The
      // following signatures are all different:
      // * function (...rest, foo, bar)
      // * function (foo, ...rest, bar)
      // * function (foo, bar, ...rest)
      // For now, just ignore rest parameters...
      if (key.indexOf('...') === 0) {
        continue
      }

      // If there is a default value defined, remove it from the
      // key.
      key = key.replace(/\s*=.*$/, '')

      // TODO: Should we do something with destructuring
      // assignments?

      signature.push(key)
    }

    return signature
  }
  else {
    return []
  }
}
1235649
def parse_property_signature(sig):
    
    match = PROP_SIG_RE.match(sig.strip())
    if not match:
        raise RuntimeError('Property signature invalid: ' + sig)
    groups = match.groups()
    if groups[0] is not None:
        modifiers = [x.strip() for x in groups[:-4]]
        groups = groups[-4:]
    else:
        modifiers = []
        groups = groups[1:]
    typ, name, getter, setter = groups
    return (modifiers, typ, name, getter is not None, setter is not None)
173725
def get_signature(token, contextable=False, comparison=False):
    
    bits = split(token.contents)
    args, kwargs = (), {}
    if comparison and bits[-1] == 'negate':
        kwargs['negate'] = True
        bits = bits[:-1]
    if contextable and len(bits) > 2 and bits[-2] == 'as':
        kwargs['varname'] = bits[-1]
        bits = bits[:-2]
    kwarg_re = re.compile(r'^([-\w]+)\=(.*)$')
    for bit in bits[1:]:
        match = kwarg_re.match(bit)
        if match:
            kwargs[str(match.group(1))] = force_unicode(match.group(2))
        else:
            args += (bit,)
    return bits[0], args, kwargs