Additional method for replacing input arguments by demo ones.
356007
def demo_args(self):
        
        argv = random.choice(self.examples).replace("--demo", "")
        self._reparse_args['pos'] = shlex.split(argv)
791124
def replace_argument(script, from_, to):
    """"""
    replaced_in_the_end = re.sub(u' {}$'.format(re.escape(from_)), u' {}'.format(to),
                                 script, count=1)
    if replaced_in_the_end != script:
        return replaced_in_the_end
    else:
        return script.replace(
            u' {} '.format(from_), u' {} '.format(to), 1)
1142532
def replace(input, **pars):
    
    pixvalue = pars.get('pixvalue', np.nan)
    if pixvalue is None: pixvalue = np.nan # insure that None == np.nan

    newvalue = pars.get('newvalue', 0.0)
    ext = pars.get('ext',None)
    if ext in ['',' ','None',None]:
        ext = None

    files = parseinput.parseinput(input)[0]

    for f in files:
        fimg = fits.open(f, mode='update', memmap=False)

        if ext is None:
            # replace pixels in ALL extensions
            extn = [i for i in fimg]
        else:
            if type(ext) == type([]):
                extn = [fimg[e] for e in ext]
            else:
                extn = [fimg[ext]]

        for e in extn:
            if e.data is not None and e.is_image: # ignore empty Primary HDUs
                print("Converting {}[{},{}] value of {} to {}".format(
                        f,e.name,e.ver,pixvalue,newvalue))
                if np.isnan(pixvalue):
                    e.data[np.isnan(e.data)] = newvalue
                else:
                    e.data[np.where(e.data == pixvalue)] = newvalue

        fimg.close()
1136417
def substitute_parameters
      @executables_inputs.each_pair do |exe, inputs|
        inputs.each_pair do |name, value|
          case exe
            when RightScale::RecipeInstantiation
              exe.attributes[name] = value.content
            when RightScale::RightScriptInstantiation
              exe.parameters[name] = value.content
          end
        end
      end
    end
777128
def format_argument(self, arg):
        """"""
        if isinstance(arg, float):
            return repr(arg)
        elif isinstance(arg, bool):
            return str(int(arg))
        else:
            try:
                return str(arg)
            except UnicodeEncodeError:
                # unicode characters will break the str cast, so
                # try to encode to ascii and replace the offending characters
                # with a '?' character
                logger.error("Error casting message argument to str! "
                             "Trying to encode argument to ascii.")
                if not isinstance(arg, unicode):
                    arg = arg.decode('utf-8')
                return arg.encode('ascii', 'replace')
1293823
def input(self, *args, **kwargs):
        
        errors = []

        if args and self.arg_names:
            args = list(args)
            # Replace args inline that have adapters
            for i, (key, val) in enumerate(izip(self.arg_names, args)):
                try:
                    args[i] = self._adapt_param(key, val)
                except AnticipateParamError as e:
                    errors.append(e)
            args = tuple(args)

        if kwargs and self.params:
            # Adapt all adaptable arguments
            for key, val in kwargs.items():
                try:
                    kwargs[key] = self._adapt_param(key, val)
                except AnticipateParamError as e:
                    errors.append(e)

        if errors:
            raise AnticipateErrors(
                message='Invalid input for %s' % self.func,
                errors=errors)

        return args, kwargs
348573
def remove_arg(self, arg):
        """"""

        self.args = [arg_.strip() for arg_ in self.args if arg_.strip()]

        for arg_ in list(self.args):
            if arg_.lower() == arg.lower():
                self.args.remove(arg_)
1238658
def replace(*args)
      arguments(args, required: [:user, :repo, :number])
      params = arguments.params
      params['data'] = arguments.remaining unless arguments.remaining.empty?

      put_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/labels", params)
    end
830105
def reassign_arguments(self):
        """"""
        condition = (
            "variable-list" in self.arguments and
            "list-of-flags" not in self.arguments
        )
        if condition:
            self.arguments["list-of-flags"] = (
                self.arguments.pop("variable-list"))
            self.rargs_cnt = 1
482214
def append_args(self, arg):
      
      debug.log("Adding Arguments: %s"%(arg))
      if isinstance(arg, (int,float)): self.args.append(str(arg))
      if isinstance(arg, str): self.args.append(arg)
      if isinstance(arg, list):
         if sys.version_info < (3, 0):
            self.args.extend([str(x) if not isinstance(x, (unicode)) else x.encode('utf-8') for x in arg])
         else:
            self.args.extend([str(x) for x in arg])
347657
private static void replaceParameters(Term t, StringBuilder b) {
        FunctionEnum f = t.getFunctionEnum();
        String fx = f.getShortestForm();
        b.append(fx).append("(");
        if (hasItems(t.getFunctionArguments())) {
            for (BELObject bo : t.getFunctionArguments()) {
                if (Term.class.isAssignableFrom(bo.getClass())) {
                    Term inner = (Term) bo;
                    if (inner.getFunctionEnum() == PROTEIN_MODIFICATION ||
                        inner.getFunctionEnum() == SUBSTITUTION ||
                        inner.getFunctionEnum() == TRUNCATION) {
                        b.append(inner.toBELShortForm());
                    } else {
                        replaceParameters((Term) bo, b);
                    }
                } else {
                    b.append("#");
                }
                b.append(",");
            }
            b.deleteCharAt(b.length() - 1);
            b.append(")");
        }
    }
1084335
def replace_argument(self, name, *args, **kwargs):
        
        new_arg = self.argument_class(name, *args, **kwargs)
        for index, arg in enumerate(self.args[:]):
            if new_arg.name == arg.name:
                del self.args[index]
                self.args.append(new_arg)
                break
        return self
276152
def combine_inputs(self, args, kw, ignore_args):
        ""
        inputs= args + tuple(c[1] for c in sorted(kw.items(), key=lambda x: x[0]))
        # REMOVE the ignored arguments from input and PREVENT it from being checked!!!
        return [a for i,a in enumerate(inputs) if i not in ignore_args]
904670
def _update_file_args(self, file_mapping):
        """"""
        for key, value in self.args.items():
            new_value = file_mapping.get(value, value)
            if new_value != value:
                self.args[key] = new_value
266398
def _replace_service_arg(self, name, index, args):
        
        args[index] = self.get_instantiated_service(name)
892536
function replace_params(params) {
	return function replace_params_(match, key) {
		if(params && params.hasOwnProperty(key)) {
			var value = params[key];
			delete params[key];
			return value;
		}
		return ':' + key;
	};
}
284909
function TransformPlaceholderArgs({
    rawDependencies,
    args,
    replaceArgs = {}
}) {
    const dependencies = [...rawDependencies];
    // clone

    const dependenciesArgs = dependencies.map((dependency, i) => {
        const arg = args[i];
        if (dependency && replaceArgs[dependency]) {
            return replaceArgs[dependency];
        }
        return arg;
    });
    return [...dependenciesArgs, ...args.slice(dependenciesArgs.length)];
}