Return a function to patch a subroutine result into a parent list
552519
function edit(inst, list, index, argv, event, fin) {
    return function editCallback(err, data) {
        if (err) return fin(err);
        list[index] = data;
        return fin(null, list);
    };
}
305813
def apply(self, func, *args, **kwargs):
        '''
        
        '''
        return func(self.raster, *args, **kwargs)
752806
def inheritance_patch(attrs):
    """"""
    for key, obj in attrs.items():
        if isinstance(obj, attribute):
            if getattr(obj, 'attr_write', None) == AttrWriteType.READ_WRITE:
                if not getattr(obj, 'fset', None):
                    method_name = obj.write_method_name or "write_" + key
                    obj.fset = attrs.get(method_name)
308683
def recursive_apply(inval, func):
    '''
    '''
    if isinstance(inval, dict):
        return {k: recursive_apply(v, func) for k, v in inval.items()}
    elif isinstance(inval, list):
        return [recursive_apply(v, func) for v in inval]
    else:
        return func(inval)
283867
def write_ast(patched_ast_node):
    
    result = []
    for child in patched_ast_node.sorted_children:
        if isinstance(child, ast.AST):
            result.append(write_ast(child))
        else:
            result.append(child)
    return ''.join(result)
453277
function _monkeypatch(filePath, monkeyPatched, processor, complete) {
  async.waterfall(
    [
      function read(next) {
        fs.readFile(filePath, 'utf8', next);
      },

      // TODO - need to parse gyp file - this is a bit hacker
      function monkeypatch(content, next) {
        if (monkeyPatched(content)) return complete();

        _log('monkey patch %s', filePath);
        processor(content, next);
      },

      function write(content, next) {
        fs.writeFile(filePath, content, 'utf8', function(err) {
          return next(err);
        });
      },
    ],
    complete,
  );
}
1129352
def transform(func, data):
    
    out = []
    for r in data:
        out.append(func(r))
    return out
22211
def reformat(self, snip, index=None):
        """"""
        if index is not None:
            return self.reformat(snip), len(self.reformat(snip[:index]))
        else:
            return self.repl_proc(snip, reformatting=True, log=False)
195180
def list_updater(*args):
    
    neg_index = [i for v,i in izip(args, itertools.count()) if v is not None and v < 0]
    if len(neg_index) > 1:
        raise ValueError("Cannot use negative values more than once")
    if not neg_index:
        slice_list = []
        size = 0
        for arg in args:
            if arg is None:
                slice_list.append(size)
                size += 1
            else:
                slice_list.append(slice(size, size + arg))
                size += arg
    else:
        sep = neg_index[0]
        slice_list = []
        size = 0
        for arg in args[:sep]:
            if arg is None:
                slice_list.append(size)
                size += 1
            else:
                slice_list.append(slice(size, size + arg))
                size += arg
        rslice_list = []
        rsize = 0
        for arg in args[:sep:-1]:
            if arg is None:
                rslice_list.append(-1-rsize)
                rsize += 1
            else:
                rslice_list.append(slice(None if not rsize else -rsize, -(rsize + arg)))
                rsize += arg
        slice_list.append(slice(size, rsize))
        slice_list.extend(reversed(rslice_list))
    def inner_wrapper(f):
        @functools.wraps(f)
        def wrapped_updater(keys, values):
            result = f(*[values[s] for s in slice_list])
            return (keys[:len(result)], result)
        return wrapped_updater
    return inner_wrapper
1026502
def _process_list(self, l):
        
        if hasattr(self, l):
            t = getattr(self, l)

            def proc(inp):
                w = inp.strip()

                if w.startswith('`'):
                    r = re.compile(w[1:-1])
                    return [u for u in [m.group() for m in [r.match(x) for x in dir(self)] if m] if isinstance(getattr(self, u), QObject)]
                else:
                    return [w]

            return list(set([y for x in map(proc, t.split(',')) for y in x]))

        return []
767297
def add_patch(self, pset, augref):
        
        try:
            path = [ self.add_prefix(c, augref)
                     for c in augref.arg.split("/") if c ]
        except KeyError:
            # augment of a module that's not among input modules
            return
        car = path[0]
        patch = Patch(path[1:], augref)
        if car in pset:
            sel = [ x for x in pset[car] if patch.path == x.path ]
            if sel:
                sel[0].combine(patch)
            else:
                pset[car].append(patch)
        else:
            pset[car] = [patch]
467928
function (list, func, args) {
				var out = [];
				for (var i = 0, j = list.length; i < j; i++) {
					out.push([ list[i][func].apply(list[i], args), list[i] ]);
				}
				return out;
			}
993688
def singledispatch(*, nargs=None, nouts=None, ndefs=None):
    

    def wrapper(f):
        return wraps(f)(SingleDispatchFunction(f, nargs=nargs, nouts=nouts, ndefs=ndefs))

    return wrapper
1206938
function getReturn(spec_c, details, method, parent) {
  var retType = getType(getText(spec_c, 'type'), parent);
  var retDescription = (details ? getText(details, 'description') : '');
  return ((retType == 'void') ? {} : {
    type: retType,
    description: retDescription
  });
}
1347136
def main(arguments=None):   # suppress(unused-function)
    """"""
    result = _parse_arguments(arguments)
    linter_funcs = _ordered(linter_functions_from_filters,
                            result.whitelist,
                            result.blacklist)
    global_options = vars(result)
    tool_options = tool_options_from_global(global_options, len(result.files))
    any_would_run = _any_would_run(_run_lint_on_file_exceptions,
                                   result.files,
                                   result.stamp_file_path,
                                   result.log_technical_terms_to,
                                   linter_funcs,
                                   tool_options,
                                   result.fix_what_you_can)

    if any_would_run:
        for linter_function in linter_funcs.values():
            if linter_function.before_all:
                linter_function.before_all(global_options, tool_options)

        use_multiprocessing = _should_use_multiprocessing(len(result.files))
    else:
        use_multiprocessing = False

    if use_multiprocessing:
        mapper = parmap.map
    else:
        # suppress(E731)
        mapper = lambda f, i, *a: [f(*((x, ) + a)) for x in i]

    errors = list(itertools.chain(*mapper(_run_lint_on_file_stamped,
                                          result.files,
                                          result.stamp_file_path,
                                          result.log_technical_terms_to,
                                          linter_funcs,
                                          tool_options,
                                          result.fix_what_you_can)))

    for error in sorted(errors):
        _report_lint_error(error.failure, os.path.relpath(error.absolute_path))

    if any_would_run:
        for linter_funcs in linter_funcs.values():
            if linter_funcs.after_all:
                linter_funcs.after_all(global_options, tool_options)

    return len(errors)
207127
def as_list(callable):
    """"""
    @wraps(callable)
    def wrapper(value_iter):
        return [callable(value) for value in value_iter]

    return wrapper
1237601
def fix_list_arguments(self):
        """"""
        either = [list(c.children) for c in self.either.children]
        for case in either:
            case = [c for c in case if case.count(c) > 1]
            for a in [e for e in case if type(e) == Argument]:
                a.value = []
        return self