Replaces state ops with non state Placeholder ops for the apply graph.
764902
def replace_apply_state(meta_graph, state_ops, feed_map):
  """"""
  for node in meta_graph.graph_def.node:
    keys_to_purge = []
    tensor_name = node.name + ":0"
    # Verify that the node is a state op and that its due to be rewired
    # in the feedmap.
    if node.op in state_ops and tensor_name in feed_map:
      node.op = "Placeholder"
      for key in node.attr:
        # Only shape and dtype are required for Placeholder. Remove other
        # attributes.
        if key != "shape":
          keys_to_purge.append(key)
      for key in keys_to_purge:
        del node.attr[key]
      node.attr["dtype"].type = types_pb2.DT_RESOURCE
830725
def replace_aliases(cut_dict, aliases):
    """"""
    for k, v in cut_dict.items():
        for k0, v0 in aliases.items():
            cut_dict[k] = cut_dict[k].replace(k0, '(%s)' % v0)
1063024
def change_state_id(self, state_id=None):
        
        if state_id is None:
            state_id = state_id_generator(used_state_ids=[self.state_id])
        if not self.is_root_state and not self.is_root_state_of_library:
            used_ids = list(self.parent.states.keys()) + [self.parent.state_id, self.state_id]
            if state_id in used_ids:
                state_id = state_id_generator(used_state_ids=used_ids)

        self._state_id = state_id
1318553
def apply(modifications, state):
        
        count = 0
        for a in modifications:
            if _debug:
                assert a[0] in ('set', 'mv', 'map', 'rm')
                logger.debug("processing rule: %s", str(a))
            if len(a) == 3:
                operation, name, value = a
                if operation == 'set':
                    state[name] = value
                    count += 1
                elif operation == 'mv':
                    try:
                        arg = state.pop(name)
                        state[value] = arg
                        count += 1
                    except KeyError:
                        raise ClassVersionException("the previous version didn't "
                                                    "store an attribute named '{}'".format(a[1]))
                elif operation == 'map':
                    func = value
                    if hasattr(func, '__func__'):
                        func = func.__func__
                    assert callable(func)
                    state[name] = func(state[name])
                    count += 1
            elif len(a) == 2:
                operation, value = a
                if operation == 'rm':
                    state.pop(value, None)
                    count += 1
                elif operation == 'transform':
                    assert callable(value)
                    value(state)
                    count += 1

        assert count == len(modifications), 'was not able to process all modifications on state'
464033
public OperationFuture<List<AntiAffinityPolicy>> modify(List<AntiAffinityPolicy> policyRefs,
        AntiAffinityPolicyConfig modifyConfig) {

        policyRefs.forEach(ref -> modify(ref, modifyConfig));

        return new OperationFuture<>(
            policyRefs,
            new NoWaitingJobFuture()
        );
    }
461669
public static List<List<OperatorStateHandle>> applyRepartitioner(
		OperatorStateRepartitioner opStateRepartitioner,
		List<List<OperatorStateHandle>> chainOpParallelStates,
		int oldParallelism,
		int newParallelism) {

		if (chainOpParallelStates == null) {
			return Collections.emptyList();
		}

		return opStateRepartitioner.repartitionState(
			chainOpParallelStates,
			oldParallelism,
			newParallelism);
		}
629989
protected function applySearchAndReplaceOperations()
    {
        foreach (Files::getRecursiveDirectoryGenerator($this->targetPackageData['path'], null, true) as $pathAndFilename) {
            $pathInfo = pathinfo($pathAndFilename);
            if (!isset($pathInfo['filename'])) {
                continue;
            }
            if (strpos($pathAndFilename, 'Migrations/Code') !== false) {
                continue;
            }

            foreach ($this->operations['searchAndReplace'] as $operation) {
                list($search, $replacement, $filter, $regularExpression) = $operation;
                if (is_array($filter)) {
                    if ($filter !== array() && (!isset($pathInfo['extension']) || !in_array($pathInfo['extension'], $filter, true))) {
                        continue;
                    }
                } elseif (substr($pathAndFilename, -strlen($filter)) !== $filter) {
                    continue;
                }
                Tools::searchAndReplace($search, $replacement, $pathAndFilename, $regularExpression);
            }
        }
    }
368181
function(replace, count, callback) {
    return pathmap.replace(
      pathmap.chomp(this, pathmap.extname(this)), replace, callback);
  }
15565
function updateOps() {
  let value = commandInput.value.replace('\t', ''); // get rid of tabs
  let argv = yargs
    .options(yargsOptions)
		.parse(value);
		
  let files = [];
  let newFileName = '';
  let operations = [];
  if (argv._.length > 1) {
    try {
      newFileName = path.parse(argv._.pop());
      files = rename.getFileArray(argv._);
      OPTS = rename.argvToOptions(argv);
      operations = rename.getOperations(files, newFileName, OPTS);
      OPS = operations;
    } catch (ex) {
      if (ex === 'InvalidReplacementVariable') {
        operations = [{text: 'Invalid replacement variable'}];
      } else {
        operations = [{text: 'Invalid command'}];
      }
    }
  }
  
  let content = operations.map(function(value) { return value.text; }).join('\n');
  opList.setContent(content);
}
398296
private void replace(PersistentStore store, NodeAVL x, NodeAVL n) {

        if (x.isRoot()) {
            if (n != null) {
                n = n.setParent(store, null);
            }

            store.setAccessor(this, n);
        } else {
            set(store, x.getParent(store), x.isFromLeft(store), n);
        }
    }
433385
def substitute(self, var_map, cont=False, tag=None):
        
        return self.apply(substitute, var_map=var_map, cont=cont, tag=tag)
909456
function applyReplacer (value, replacer) {
  if (typeof replacer === 'function') {
    const input = {
      '': value
    }
    return applyFunctionReplacer(input, replacer)['']
  }

  if (
    isArray(replacer)
    // Array replacer only works for plain object
    && isPlainObject(value)
  ) {
    return applyFunctionReplacer(value, (k, v) => ~ replacer.indexOf(k)
      ? v
      : undefined)
  }

  return value
}
630177
function apply(destination, source, noOverwrite){
    var member;
    for (var prop in source) {
        if (source.hasOwnProperty(prop)) {
            if (prop in destination) {
                member = source[prop];
                if (typeof member === "object") {
                    apply(destination[prop], member, noOverwrite);
                }
                else if (!noOverwrite) {
                    destination[prop] = source[prop];
                }
            }
            else {
                destination[prop] = source[prop];
            }
        }
    }
    return destination;
}
45446
function applyChanges(state, changes, queryInfo) {
  if (state === undefined) return state;
  return changes.reduce(function (stateValue, change) {
    return applyChange(stateValue, change, queryInfo);
  }, state);
}
835484
public PutOperation<K, V> applyOperation(K key, PutOperation<K, V> existing, Operation<K, V> operation) {
    final Result<K, V> newValue = operation.apply(existing);
    if (newValue == null) {
      return null;
    } else {
      return newValue.asOperationExpiringAt(Long.MAX_VALUE);
    }
  }
726056
def apply_color(self, arr, state):
        """"""
        ops = self.cmd(state)
        for func in parse_operations(ops):
            arr = func(arr)
        return arr
797439
function attemptReplacePatterns(token, replacements, measureThreshold) {
  var replacement = null;

  for(var i = 0; i < replacements.length; i++) {
    if(!measureThreshold || measure(attemptReplace(token, replacements[i][0], '')) > measureThreshold)
      replacement = attemptReplace(token, replacements[i][0], replacements[i][1]);

    if(replacement)
      break;
  }

  return replacement;
}