Return .par format string for this parameter

        If dolist is set, returns fields as a list of strings.  Default
        is to return a single string appropriate for writing to a file.
961202
def save(self, dolist=0):
        
        quoted = not dolist
        array_size = 1
        for d in self.shape:
            array_size = d*array_size
        ndim = len(self.shape)
        fields = (7+2*ndim+len(self.value))*[""]
        fields[0] = self.name
        fields[1] = self.type
        fields[2] = self.mode
        fields[3] = str(ndim)
        next = 4
        for d in self.shape:
            fields[next] = str(d); next += 1
            fields[next] = '1';    next += 1
        nvstart = 7+2*ndim
        if self.choice is not None:
            schoice = list(map(self.toString, self.choice))
            schoice.insert(0,'')
            schoice.append('')
            fields[nvstart-3] = repr('|'.join(schoice))
        elif self.min not in [None,INDEF]:
            fields[nvstart-3] = self.toString(self.min,quoted=quoted)
        # insert an escaped line break before min field
        if quoted:
            fields[nvstart-3] = '\\\n' + fields[nvstart-3]
        if self.max not in [None,INDEF]:
            fields[nvstart-2] = self.toString(self.max,quoted=quoted)
        if self.prompt:
            if quoted:
                sprompt = repr(self.prompt)
            else:
                sprompt = self.prompt
            # prompt can have embedded newlines (which are printed)
            sprompt = sprompt.replace(r'\012', '\n')
            sprompt = sprompt.replace(r'\n', '\n')
            fields[nvstart-1] = sprompt
        for i in range(len(self.value)):
            fields[nvstart+i] = self.toString(self.value[i],quoted=quoted)
        # insert an escaped line break before value fields
        if dolist:
            return fields
        else:
            fields[nvstart] = '\\\n' + fields[nvstart]
            return ','.join(fields)
163081
def _write_parameter_file(params):
    
    
    # Get path
    path = os.path.join(get_tempdir(), 'params.txt')
    
    # Define helper function
    def valToStr(val):
        if val in [True, False]:
            return '"%s"' % str(val).lower()
        elif isinstance(val, int):
            return str(val)
        elif isinstance(val, float):
            tmp = str(val)
            if not '.' in tmp:
                tmp += '.0'
            return tmp
        elif isinstance(val, str):
            return '"%s"' % val
    
    # Compile text
    text = ''
    for key in params:
        val = params[key]
        # Make a string of the values
        if isinstance(val, (list, tuple)):
            vals = [valToStr(v) for v in val]
            val_ = ' '.join(vals)
        else:
            val_ = valToStr(val)
        # Create line and add
        line = '(%s %s)' % (key, val_)
        text += line + '\n'
    
    # Write text
    f = open(path, 'wb')
    try:
        f.write(text.encode('utf-8'))
    finally:
        f.close()
    
    # Done
    return path
317881
def extract_fields(d, fields, delimiter='|'):
    
    rd = {}
    for f in fields:
        v = d.get(f, None)
        if isinstance(v, (str, unicode)):
            v = v.encode('utf8')
        elif isinstance(v, list):
            v = delimiter.join(v)
        rd[f] = v
    return rd
698787
def parse_string(self, string=''):
        '''
        
        '''
        self.strings = string.splitlines(1)
        self.strings = [self.__parse(line) for line in self.strings]
        return ''.join(self.strings)
1162456
def prepare_fields(fields):
    
    def process_item(value):
        if not isinstance(value, NUMERIC_TYPES):
            if isinstance(value, six.string_types):
                # encode utf-8 to unicode, if necessary
                return force_text(value)
            else:
                if isinstance(value, dict):
                    return prepare_fields(value)
                elif isinstance(value, list):
                    return list(map(process_item, value))

                return six.text_type(value)
        return value

    return dict((key, process_item(value))
                for key, value
                in fields.items())
294663
function format(f) {
  var i = 1;
  var args = arguments;
  var len = args.length;
  var str = String(f).replace(formatRegExp, function(x) {
    if (x === '%%') { return '%'; }
    if (i >= len) { return x; }
    switch (x) {
      case '%s':
        return String(args[i++]);
      case '%d':
        return Number(args[i++]);
      case '%j':
        return JSON.stringify(args[i++]);
      default:
        return x;
    }
  });
  return str;
}
344457
def format_return_text(self, data, function, **kwargs):  # pylint: disable=unused-argument
        '''
        
        '''
        # emulate the yaml_out output formatter. It relies on a global __opts__ object which
        # we can't obviously pass in
        try:
            try:
                outputter = data[next(iter(data))].get('out')
            except (StopIteration, AttributeError):
                outputter = None
            return salt.output.string_format(
                {x: y['return'] for x, y in six.iteritems(data)},
                out=outputter,
                opts=__opts__,
            )
        except Exception as exc:
            import pprint
            log.exception(
                'Exception encountered when trying to serialize %s',
                pprint.pformat(data)
            )
            return 'Got an error trying to serialze/clean up the response'
595371
function formatType(node) {
  let result;

  if (!node) {
    return [t('any')];
  }

  switch (node.type) {
    case Syntax.NullableLiteral:
      return [t('?')];
    case Syntax.AllLiteral:
      return [t('any')];
    case Syntax.NullLiteral:
      return [t('null')];
    case Syntax.VoidLiteral:
      return [t('void')];
    case Syntax.UndefinedLiteral:
      return [t('undefined')];
    case Syntax.NameExpression:
      return [t(node.name)];
    case Syntax.ParameterType:
      result = [];

      if (node.name) {
        result.push(c(node.name), t(': '));
      }

      return result.concat(formatType(node.expression));

    case Syntax.TypeApplication:
      return formatType(node.expression).concat(
        commaList(node.applications, '<', '>'),
      );
    case Syntax.UnionType:
      return commaList(node.elements, '(', ')', ' | ');

    case Syntax.ArrayType:
      return commaList(node.elements, '[', ']');
    case Syntax.RecordType:
      return commaList(node.fields, '{', '}');

    case Syntax.FieldType:
      if (node.value) {
        return [t(node.key + ': ')].concat(formatType(node.value));
      }
      return [t(node.key)];

    case Syntax.FunctionType:
      result = [t('function(')];

      if (node['this']) {
        if (node['new']) {
          result.push(t('new: '));
        } else {
          result.push(t('this: '));
        }

        result = result.concat(formatType(node['this']));

        if (node.params.length !== 0) {
          result.push(t(', '));
        }
      }

      result = result.concat(commaList(node.params, '', ')'));

      if (node.result) {
        result = result.concat([t(': ')].concat(formatType(node.result)));
      }
      return result;

    case Syntax.RestType:
      // note that here we diverge from doctrine itself, which
      // lets the expression be omitted.
      return [t('...'), ...formatType(node.expression)];
    case Syntax.OptionalType:
      if (node.default) {
        return [
          ...formatType(node.expression),
          t('?'),
          t('= ' + c(node.default)),
        ];
      }
      return [...formatType(node.expression), t('?')];
    case Syntax.NonNullableType:
      return node.prefix
        ? [t('?'), ...formatType(node.expression)]
        : [...formatType(node.expression), t('?')];
    case Syntax.NullableType:
      return [...formatType(node.expression), t('?')];
    case Syntax.StringLiteralType:
      return [c(JSON.stringify(node.value))];
    case Syntax.NumericLiteralType:
    case Syntax.BooleanLiteralType:
      return [c(String(node.value))];

    default:
      throw new Error('Unknown type ' + node.type);
  }
}
284862
def apply_format(var, format_str):
    
    if isinstance(var, (list, tuple)):
        new_var = map(lambda x: apply_format(x, format_str), var)
        if isinstance(var, tuple):
            new_var = '(' + ', '.join(new_var) + ')'
        elif isinstance(var, list):
            new_var = '[' + ', '.join(new_var) + ']'
        return '{}'.format(new_var)
    else:
        return format_str.format(var)
699851
def formatter_help(cls):
        
        result = [("raw", "Switch off the default field formatter.")]

        for name, method in globals().items():
            if name.startswith("fmt_"):
                result.append((name[4:], method.__doc__.strip()))

        return result
1269868
function format(f) {
    "use strict";
    var i = 1;
    var args = arguments;
    var len = args.length;
    var str = String(f).replace(/%[sdj%]/g, function _replace(x) {
        if (i >= len) return x;
        switch (x) {
        case '%s':
            return String(args[i++]);
        case '%d':
            return Number(args[i++]);
        case '%j':
            return JSON.stringify(args[i++]);
        case '%%':
            return '%';
        default:
            return x;
        }
    });
    for (var x = args[i]; i < len; x = args[++i]) {
        if (x === null || typeof x !== 'object') {
            str += ' ' + x;
        } else {
            str += '[obj]';
        }
    }
    return str;
}
232548
def add_string_parameters(self, string):
        
        if isinstance(string, list):
            for x in string:
                self.add_string_parameters(x)
            return
        self._parameters.append("{ \"value\": \"" + string + "\" }")
112601
def parse_fields(cls, formatter):
        ""
        if formatter is None: return []
        try:
            parse = list(string.Formatter().parse(formatter))
            return  set(f for f in list(zip(*parse))[1] if f is not None)
        except:
            raise SyntaxError("Could not parse formatter %r" % formatter)
1145959
private String listToString(List<String> stringList){
		StringBuilder concat = new StringBuilder();
		for(String str:stringList){
			concat.append(str);
			concat.append(System.getProperty("line.separator"));
		}
		return concat.toString();
	}
951283
function(opt, field_name, default_value) {
    if(typeof field_name === 'string') {
      // case of single string
      return (typeof opt[field_name] !== 'undefined') ? opt[field_name] : default_value;
    } else {
      // assume we are given a list of string instead
      var ret = default_value;
      for(var i=0;i<field_name.length;i++) {
        var f = field_name[i];
        if (typeof opt[f] !== 'undefined') {
          ret = opt[f]; // overwrite return value
        }
      }
      return ret;
    }
  }
26213
def list_to_str(list, separator=','):
    
    list = [str(x) for x in list]
    return separator.join(list)
743129
@Override
	public String formatParams() {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < bindNames.size(); i++) {
			sb.append(String.format("[%s=%s]", bindNames.get(i), bindValiables.get(i)));
		}
		return sb.toString();
	}