:reek:UtilityFunction
427298
def insert_spacing! lines, comments
      comment_count = comments.size

      return if comments.empty?
      return if lines.size == 1
      return if lines[comment_count] == "\n"

      lines.insert comment_count, "\n"
    end
1286429
function f (data, opts, callback) {
  data = unpack(data)

  if (!callback) {
    [callback, opts] = [opts, {}]
  }

  let match = opts.match || /\sx($|\s)/
  let need = []

  for (let browser in data.stats) {
    let versions = data.stats[browser]
    for (let version in versions) {
      let support = versions[version]
      if (support.match(match)) {
        need.push(browser + ' ' + version)
      }
    }
  }

  callback(need.sort(browsersSort))
}
323786
function(value, context, argCount) {
                if (value == null) return _.identity;
                if (_.isFunction(value)) return optimizeCb(value, context, argCount);
                if (_.isObject(value)) return _.matcher(value);
                return _.property(value);
              }
1094903
def arg_lookup(fun, aspec=None):
    '''
    
    '''
    ret = {'kwargs': {}}
    if aspec is None:
        aspec = get_function_argspec(fun)
    if aspec.defaults:
        ret['kwargs'] = dict(zip(aspec.args[::-1], aspec.defaults[::-1]))
    ret['args'] = [arg for arg in aspec.args if arg not in ret['kwargs']]
    return ret
23448
function cprModFunction (a, b) {
  let res = a % b
  if (res < 0) res += b
  return res
}
820327
def ui_func(cls, id_, name, function_type, avail_fn=always):
    """"""
    return cls(id_, name, 0, 0, function_type, FUNCTION_TYPES[function_type],
               avail_fn)
913239
def lazy_property(function):
    
    cached_val = []
    def _wrapper(*args):
        try:
            return cached_val[0]
        except IndexError:
            ret_val = function(*args)
            cached_val.append(ret_val)
            return ret_val
    return _wrapper
1105155
def none_returns(func):
    

    @functools.wraps(func)
    def _execute(*args, **kwargs):
        """Executes function, if error returns None else value of function

        :param args: args of function
        :param kwargs: extra args of function
        :param *args: args
        :param **kwargs: extra args
        :return: None else value of function
        """

        try:
            return func(*args, **kwargs)
        except:
            return None

    return _execute
660342
def filter_by_func(self, func:Callable)->'ItemList':
        ""
        self.items = array([o for o in self.items if func(o)])
        return self
16905
function TradingWrapper(apiKeyOrParams, apiSecret, nonceGen) {
    // Assume first parameter (i.e. apiKeyOrParams) is a params package
    let params = apiKeyOrParams;

    // Try to prove this assumption wrong
    if (params === null || typeof params !== "object") {
        // Pack parameters if so
        params = {
            apiKey: apiKeyOrParams,
            apiSecret: apiSecret,
            nonceGen: nonceGen
        };
    }

    // Assert parameter expectations
    ParamUtils.expectParams(params, {
        apiKey: "string",
        apiSecret: "string",
        nonceGen: {type: "function", opt: true}
    });

    this._apiKey = params.apiKey;
    this._apiSecret = params.apiSecret;
    this._nonceGen = params.nonceGen;
}
395477
def _relu(x, leakiness=0.0):
  """"""
  return tf.where(tf.less(x, 0.0), leakiness * x, x, name='leaky_relu')
1353928
def pipe_util(func):
    
    @wraps(func)
    def pipe_util_wrapper(function, *args, **kwargs):
        if isinstance(function, XObject):
            function = ~function

        original_function = function

        if args or kwargs:
            function = xpartial(function, *args, **kwargs)

        name = lambda: '%s(%s)' % (get_name(func), ', '.join(
            filter(None, (get_name(original_function), repr_args(*args, **kwargs)))))

        f = func(function)

        result = pipe | set_name(name, f)

        # if the util defines an 'attrs' mapping, copy it as attributes
        # to the result
        attrs = getattr(f, 'attrs', {})
        for k, v in dict_items(attrs):
            setattr(result, k, v)

        return result

    return pipe_util_wrapper
864196
def find(self, func):
        
        self.ftmp = None

        def test(value, index, list):
            if func(value, index, list) is True:
                self.ftmp = value
                return True
        self._clean.any(test)
        return self._wrap(self.ftmp)
1159730
def replace_cleanup_func(self, func, only_read=False):
        
        self.logger.info('Replace the cleanup function %s ---> %s' % (
            get_function_signature(self.cleanup), get_function_signature(func)))
        self.cleanup = func
        return True
610698
def getfunc(obj, name=''):
    ''''''
    if name:
        obj = getattr(obj, name)
    return getattr(obj, '__func__', obj)
492564
def get_fun(fun):
    '''
    
    '''
    log.debug('sdstack_etcd returner <get_fun> called fun: %s', fun)
    ret = {}
    client, path = _get_conn(__opts__)
    items = client.get('/'.join((path, 'minions')))
    for item in items.children:
        comps = str(item.key).split('/')
        efun = salt.utils.json.loads(client.get('/'.join((path, 'jobs', str(item.value), comps[-1], 'fun'))).value)
        if efun == fun:
            ret[comps[-1]] = str(efun)
    return ret
1340569
def _Function(self, t):
        
        if t.decorators is not None:
            self._fill("@")
            self._dispatch(t.decorators)
        self._fill("def "+t.name + "(")
        defaults = [None] * (len(t.argnames) - len(t.defaults)) + list(t.defaults)
        for i, arg in enumerate(zip(t.argnames, defaults)):
            self._write(arg[0])
            if arg[1] is not None:
                self._write('=')
                self._dispatch(arg[1])
            if i < len(t.argnames)-1:
                self._write(', ')
        self._write(")")
        if self._single_func:
            self._do_indent = False
        self._enter()
        self._dispatch(t.code)
        self._leave()
        self._do_indent = True