Add patch corresponding to `augref` to `pset`.

        `augref` must be either 'augment' or 'refine' statement.
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]
391696
def combine(self, patch):
        """"""
        exclusive = set(["config", "default", "mandatory", "presence",
                     "min-elements", "max-elements"])
        kws = set([s.keyword for s in self.plist]) & exclusive
        add = [n for n in patch.plist if n.keyword not in kws]
        self.plist.extend(add)
237437
def patch_func(replacement, target_mod, func_name):
    
    original = getattr(target_mod, func_name)

    # set the 'unpatched' attribute on the replacement to
    # point to the original.
    vars(replacement).setdefault('unpatched', original)

    # replace the function in the original module
    setattr(target_mod, func_name, replacement)
1191086
def _AugAssign(self, t):
        

        self._fill()
        self._dispatch(t.node)
        self._write(' '+t.op+' ')
        self._dispatch(t.expr)
        if not self._do_indent:
            self._write(';')
139640
def _modify(self, **patch):
        """"""

        requests_params, patch_uri, session, read_only = \
            self._prepare_put_or_patch(patch)
        self._check_for_boolean_pair_reduction(patch)
        read_only_mutations = []
        for attr in read_only:
            if attr in patch:
                read_only_mutations.append(attr)
        if read_only_mutations:
            msg = 'Attempted to mutate read-only attribute(s): %s' \
                % read_only_mutations
            raise AttemptedMutationOfReadOnly(msg)

        patch = self._prepare_request_json(patch)
        response = session.patch(patch_uri, json=patch, **requests_params)
        self._local_update(response.json())
1199724
def patch(self, delta):
        ""
        return self.api.post('path/sync/patch', self.path, delta=delta)
290993
def apply_patch(diffs):
    
    pass

    if isinstance(diffs, patch.diff):
        diffs = [diffs]

    for diff in diffs:
        if diff.header.old_path == '/dev/null':
            text = []
        else:
            with open(diff.header.old_path) as f:
                text = f.read()

        new_text = apply_diff(diff, text)
        with open(diff.header.new_path, 'w') as f:
            f.write(new_text)
1186976
def apply_patch(operations, node)
      i = 0
      operations.sort_by {|operation| i += 1; [-operation.priority, i] }.each do |operation|
        case operation
        when ::Markdiff::Operations::AddChildOperation
          operation.target_node.add_child(operation.inserted_node)
          mark_li_or_tr_as_changed(operation.target_node)
          mark_top_level_node_as_changed(operation.target_node)
        when ::Markdiff::Operations::AddDataBeforeHrefOperation
          operation.target_node["data-before-href"] = operation.target_node["href"]
          operation.target_node["href"] = operation.after_href
          mark_li_or_tr_as_changed(operation.target_node)
          mark_top_level_node_as_changed(operation.target_node)
        when ::Markdiff::Operations::AddDataBeforeTagNameOperation
          operation.target_node["data-before-tag-name"] = operation.target_node.name
          operation.target_node.name = operation.after_tag_name
          mark_li_or_tr_as_changed(operation.target_node)
          mark_top_level_node_as_changed(operation.target_node)
        when ::Markdiff::Operations::AddPreviousSiblingOperation
          operation.target_node.add_previous_sibling(operation.inserted_node)
          mark_li_or_tr_as_changed(operation.target_node) if operation.target_node.name != "li" && operation.target_node.name != "tr"
          mark_top_level_node_as_changed(operation.target_node.parent)
        when ::Markdiff::Operations::RemoveOperation
          operation.target_node.replace(operation.inserted_node) if operation.target_node != operation.inserted_node
          mark_li_or_tr_as_changed(operation.target_node)
          mark_top_level_node_as_changed(operation.target_node)
        when ::Markdiff::Operations::TextDiffOperation
          parent = operation.target_node.parent
          operation.target_node.replace(operation.inserted_node)
          mark_li_or_tr_as_changed(parent)
          mark_top_level_node_as_changed(parent)
        end
      end
      node
    end
46509
def patch_addContext(self, patch, text):
    
    if len(text) == 0:
      return
    pattern = text[patch.start2 : patch.start2 + patch.length1]
    padding = 0

    # Look for the first and last matches of pattern in text.  If two different
    # matches are found, increase the pattern length.
    while (text.find(pattern) != text.rfind(pattern) and (self.Match_MaxBits ==
        0 or len(pattern) < self.Match_MaxBits - self.Patch_Margin -
        self.Patch_Margin)):
      padding += self.Patch_Margin
      pattern = text[max(0, patch.start2 - padding) :
                     patch.start2 + patch.length1 + padding]
    # Add one chunk for good luck.
    padding += self.Patch_Margin

    # Add the prefix.
    prefix = text[max(0, patch.start2 - padding) : patch.start2]
    if prefix:
      patch.diffs[:0] = [(self.DIFF_EQUAL, prefix)]
    # Add the suffix.
    suffix = text[patch.start2 + patch.length1 :
                  patch.start2 + patch.length1 + padding]
    if suffix:
      patch.diffs.append((self.DIFF_EQUAL, suffix))

    # Roll back the start points.
    patch.start1 -= len(prefix)
    patch.start2 -= len(prefix)
    # Extend lengths.
    patch.length1 += len(prefix) + len(suffix)
    patch.length2 += len(prefix) + len(suffix)
333858
def addContinuousSet(self):
        
        self._openRepo()
        dataset = self._repo.getDatasetByName(self._args.datasetName)
        filePath = self._getFilePath(self._args.filePath,
                                     self._args.relativePath)
        name = getNameFromPath(self._args.filePath)
        continuousSet = continuous.FileContinuousSet(dataset, name)
        referenceSetName = self._args.referenceSetName
        if referenceSetName is None:
            raise exceptions.RepoManagerException(
                "A reference set name must be provided")
        referenceSet = self._repo.getReferenceSetByName(referenceSetName)
        continuousSet.setReferenceSet(referenceSet)
        continuousSet.populateFromFile(filePath)
        self._updateRepo(self._repo.insertContinuousSet, continuousSet)
303605
def add_new_refs(cls, manifest, current_project, node, macros):
        
        manifest = manifest.deepcopy(config=current_project)
        # it's ok for macros to silently override a local project macro name
        manifest.macros.update(macros)

        if node.unique_id in manifest.nodes:
            # this should be _impossible_ due to the fact that rpc calls get
            # a unique ID that starts with 'rpc'!
            raise dbt.exceptions.raise_duplicate_resource_name(
                manifest.nodes[node.unique_id], node
            )
        manifest.nodes[node.unique_id] = node
        cls.process_sources_for_node(manifest, current_project, node)
        cls.process_refs_for_node(manifest, current_project, node)
        cls.process_docs_for_node(manifest, current_project, node)
        return manifest
5311
def apply_fixes(args, tmpdir):
  """"""
  invocation = [args.clang_apply_replacements_binary]
  if args.format:
    invocation.append('-format')
  if args.style:
    invocation.append('-style=' + args.style)
  invocation.append(tmpdir)
  subprocess.call(invocation)
992790
function patchIt(specs) {
  var original = it;
  var restore = function() {
    it = original;
    xit = it.skip;
  };

  var createSpec = function(name, fn, opts) {
    opts = opts || {};

    var spec = {
      name: name,
      getPromise: function() {
        var start = Date.now();
        return createWrapper(fn, spec.ctx)().then(function(duration) {
          spec.duration = duration;
        });
      },
      duration: 0,
      only: opts.only || null,
      skip: opts.skip || null,
      timeout: null,
      error: null,
      promise: null
    };

    spec.ctx = new ContextProxy(spec);
    specs.push(spec);
  };

  it = function it(name, fn) {
    createSpec(name, fn, {skip: !fn});
  };

  xit = it.skip = function skip(name, fn) {
    createSpec(name, fn, {skip: true});
  };

  it.only = function only(name, fn) {
    createSpec(name, fn, {only: true});
  };

  return restore;
}
494307
def patch(self):
        
        from django.db.models.sql import compiler

        self._read_compilers = (
            compiler.SQLCompiler,
            compiler.SQLAggregateCompiler,
            compiler.SQLDateCompiler,
        )
        self._write_compilers = (
            compiler.SQLInsertCompiler,
            compiler.SQLDeleteCompiler,
            compiler.SQLUpdateCompiler,
        )
        if not self._patched:
            self._original = {}
            for reader in self._read_compilers:
                self._original[reader] = reader.execute_sql
                reader.execute_sql = self._monkey_select(reader.execute_sql)
            for updater in self._write_compilers:
                self._original[updater] = updater.execute_sql
                updater.execute_sql = self._monkey_write(updater.execute_sql)
            self._patched = True
            self.cache_backend.patch()
            self._handle_signals()
893178
def _inject_patched_examples(self, existing_item, patched_item):
        """"""
        for key, _ in patched_item.examples.items():
            patched_example = patched_item.examples[key]
            existing_examples = existing_item.examples
            if key in existing_examples:
                existing_examples[key].fields.update(patched_example.fields)
            else:
                error_msg = 'Example defined in patch {} must correspond to a pre-existing example.'
                raise InvalidSpec(error_msg.format(
                    quote(patched_item.name)), patched_example.lineno, patched_example.path)
88328
function compile(patch) {
  var code = "";
  patch.forEach(function(op) {
    var o = "";
    switch (op.op) {
      case "remove":
        o += "delete " + pathToStatement(op.path);
        break;
      case "add":
        o += pathToStatement(op.path) + " = " + JSON.stringify(op.value);
        break;
      case "replace":
        o += pathToStatement(op.path) + " = " + JSON.stringify(op.value);
        break;
      case "move":
        var from = pathToStatement(op.from);
        o += pathToStatement(op.path) + " = " + from + ";\n";
        o += "delete " + from;
        break;
      case "copy":
        o += pathToStatement(op.path) + " = " + from;
        break;
      case "test":
        o +=
          "if (!oo.equal(" +
          pathToStatement(op.path) +
          ", " +
          JSON.stringify(op.value) +
          ") throw new Error()";
        break;
    }
    code += o + ";\n";
  });
  return code;
}
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)