Build a list of ``(name, value)`` pairs for some compression parameters.
502715
def _build_parameters(
    server_no_context_takeover: bool,
    client_no_context_takeover: bool,
    server_max_window_bits: Optional[int],
    client_max_window_bits: Optional[Union[int, bool]],
) -> List[ExtensionParameter]:
    
    params: List[ExtensionParameter] = []
    if server_no_context_takeover:
        params.append(("server_no_context_takeover", None))
    if client_no_context_takeover:
        params.append(("client_no_context_takeover", None))
    if server_max_window_bits:
        params.append(("server_max_window_bits", str(server_max_window_bits)))
    if client_max_window_bits is True:  # only in handshake requests
        params.append(("client_max_window_bits", None))
    elif client_max_window_bits:
        params.append(("client_max_window_bits", str(client_max_window_bits)))
    return params
567598
def prepare_params(req: snug.Request) -> snug.Request:
    """"""
    return req.replace(
        params={key: dump_param(val) for key, val in req.params.items()
                if val is not None})
1122520
def extend_values(dictionary, key, items):
    """"""
    values = dictionary.get(key, [])
    try:
        values.extend(items)
    except TypeError:
        raise TypeError('Expected a list, got: %r' % items)
    dictionary[key] = values
959148
def param_dict_to_str(data):
    """"""
    if data is None or not data:
        return ""
    pairs = []
    for key, val in data.items():
        if isinstance(val, (list, tuple, set)) or is_numpy_1d_array(val):
            pairs.append(str(key) + '=' + ','.join(map(str, val)))
        elif isinstance(val, string_type) or isinstance(val, numeric_types) or is_numeric(val):
            pairs.append(str(key) + '=' + str(val))
        elif val is not None:
            raise TypeError('Unknown type of parameter:%s, got:%s'
                            % (key, type(val).__name__))
    return ' '.join(pairs)
805
def compress(self, d=DEFAULT):
        """"""
        if d is DEFAULT:
            d = self
        if isinstance(d, list):
            l = [v for v in (self.compress(v) for v in d)]
            try:
                return list(set(l))
            except TypeError:
                # list contains not hashables
                ret = []
                for i in l:
                    if i not in ret:
                        ret.append(i)
                return ret
        elif isinstance(d, type(self)):
            return type(self)({k: v for k, v in ((k, self.compress(v)) for k, v in d.items())})
        elif isinstance(d, dict):
            return {k: v for k, v in ((k, self.compress(v)) for k, v in d.items())}
        return d
374542
def _make_sql_params(self,kw):
        """"""
        vals = []
        for k,v in kw.iteritems():
            vals.append('%s=%s' %(k,self._conv(v)))
        return vals
447699
def __build_query(self, routine, parameters):
        """"""

        parameter_names = []
        replacements = {}
        for i, value in enumerate(parameters):
            name = 'arg' + str(i)

            parameter_names.append(name)
            replacements[name] = value

        parameter_pieces = []
        for i, name in enumerate(parameter_names):
            if i > 0:
                parameter_pieces.append(', ')

            # Embed encoded blobs directly.
            if issubclass(replacements[name].__class__, _BlobArgumentWrapper) is True:
                parameter_pieces.append(replacements[name].encoded)
                del replacements[name]
            else:
                parameter_pieces.append(':' + name)

        query = "CALL " + routine + "(" + ''.join(parameter_pieces) + ")"

        return (query, replacements)
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)))
228277
function zip(keys, values) {
  if (keys.length !== values.length) {
    throw Error(`Incorrect number of arguments, expected: ${keys.length}, arguments received: ${values.join(', ')}`)
  }

  return keys.reduce((all, key, idx) => ({...all, [key]: values[idx]}), {})
}
1352768
def _create_list(value, allow_filename=False):
    
    if isinstance(value, list):
        return value
    elif isinstance(value, string_type):
        if allow_filename and os.path.isfile(value):
            with codecs.open(value, 'r', encoding="utf-8") as handle:
                return handle.read().splitlines()
        return value.split(',')
    else:
        raise ValueError("Can't create list for input {}".format(value))
282430
def _Pairs(data):
    """"""
    keys = sorted(data)
    return [{'@key': k, '@value': data[k]} for k in keys]
1927
def encode_matrix_parameters(parameters):
    
    result = []

    for param in iter(sorted(parameters)):
        if isinstance(parameters[param], (list, tuple)):
            value = (';%s=' % (param)).join(parameters[param])
        else:
            value = parameters[param]

        result.append("%s=%s" % (param, value))

    return ';'.join(result)
991002
def _wrap(self, value):
        
        if isinstance(value, dict):
            if any(isinstance(name, int) for name in value.keys()):
                if not all(isinstance(name, int) for name in value.keys()):
                    raise RuntimeError("Integer and non-integer keys: %r"
                                       % value.keys())
                items = sorted(value.iteritems(), key=itemgetter(0))
                return [self._wrap(val) for _, val in items]
            else:
                return Arguments(value)
        elif isinstance(value, list):
            return [self._wrap(x) for x in value]
        else:
            return value
709172
private List<String> getParameterAsList(String name) {
        String[] values = getParameterValues(name);
        if (values == null) {
            return null;
        }

        List<String> valueList = new ArrayList<>(values.length);
        Collections.addAll(valueList, values);
        return valueList;
    }
251674
def preprocess_example_common(example, mode, hparams):
  """"""
  if "inputs" in example and hparams.max_input_seq_length > 0:
    example["inputs"] = example["inputs"][:hparams.max_input_seq_length]
  if hparams.prepend_mode != "none":
    if mode == tf.estimator.ModeKeys.PREDICT:
      example["partial_targets"] = tf.concat([example["inputs"], [0]], 0)
    else:
      example["targets"] = tf.concat(
          [example["inputs"], [0], example["targets"]], 0)
  if "targets" in example and hparams.max_target_seq_length > 0:
    example["targets"] = example["targets"][:hparams.max_target_seq_length]
  if hparams.split_to_length:
    new_example = {}
    for k, v in six.iteritems(example):
      if k == "targets" or k == "inputs":
        new_example[k] = tf.reshape(v, [-1, hparams.split_to_length, 1, 1])
      else:
        tf.logging.warning("Dropping feature %s" % k)
    return tf.data.Dataset.from_tensor_slices(new_example)
  return example
991448
def zip(keys, values):
    
    output = Data()
    for i, k in enumerate(keys):
        if i >= len(values):
            break
        output[k] = values[i]
    return output
536711
def pairwise(iterable):
    ""
    a, b = tee(iterable)
    next(b, None)
    return izip(a, b)