format string to fesr compliant string
491892
function format(vField, iLength, bCutFromFront) {
		if (!vField) {
			vField = vField === 0 ? "0" : "";
		} else if (typeof vField === "number") {
			var iField = vField;
			vField = Math.round(vField).toString();
			// Calculation of figures may be erroneous because incomplete performance entries lead to negative
			// numbers. In that case we set a -1, so the "dirty" record can be identified as such.
			if (vField.length > iLength || iField < 0) {
				vField = "-1";
			}
		} else {
			vField = bCutFromFront ? vField.substr(-iLength, iLength) : vField.substr(0, iLength);
		}
		return vField;
	}
991084
def convert_value_to_text r, count
      if r == :separator
        return separator
      elsif r == :columns
        return "??" unless @columns # column was requested but not supplied
        # FIXME putting entire header into this, take care of hidden
        r = []
        @columns.each_with_index { |e, i| r << e unless get_column(i).hidden  }
        return @headerfmtstr % r if @numbering
      end
      str = ""

      if @numbering
        #r = r.dup
        #r.insert 0, count+1
        # TODO get the width
        str << "%*d |"%  [2, count + 1]
      end
      # unroll r, get width and align
      # This is to truncate column to requested width
      fmta = []
      r.each_with_index { |e, i| 
        next if get_column(i).hidden == true
        #w = @pw[i] || @cw[i]  # XXX
        #$log.debug "WIDTH XXX  #{i} w= #{w} , #{@pw[i]}, #{@cw[i]} :: #{e} " if $log.debug? 
        w = @cw[i]
        l = e.to_s.length
        fmt = "%-#{w}s "
        # if value is longer than width, then truncate it
        if l > w
          fmt = "%.#{w}s "
        else
          # ack we don;t need to recalc this we can pull out of hash FIXME
          case @calign[i]
          when :right
            fmt = "%#{w}s "
          else
            fmt = "%-#{w}s "
          end
        end
        str << fmt % e
        fmta << fmt
      }
      #fmstr = fmta.join(@y)
      #return fmstr % r; # FIXME hidden column still goes int 
      return str
    end
745899
def as_strings(self):
        """"""
        if self.value == '' or self.value is None:
            return '{0};\n'.format(self.name)
        if '"' not in self.value and (';' in self.value or '#' in self.value):
            return '{0} "{1}";\n'.format(self.name, self.value)
        return '{0} {1};\n'.format(self.name, self.value)
1131526
def string_format(data, out, opts=None, **kwargs):
    '''
    
    '''
    raw_output = try_printout(data, out, opts, **kwargs)
    ansi_escape = re.compile(r'\x1b[^m]*m')
    return ansi_escape.sub('', raw_output)
1113306
def parse_str(self, s):
        
        self.object = self.parsed_class()
        in_section = None  # Holds name of FEH file section while traversing through file.
        for line in s.split('\n'):
            if line.lower().startswith('[end]'):
                # Leave section
                in_section = None
            elif line.startswith('['):
                # Enter section, sanitise `[Section Name]` to `section_name`
                in_section = line.strip().strip('[]').lower().replace(' ', '_')
            elif in_section:
                try:
                    # Call method `_section_section_name(line)`
                    getattr(self, '_section_' + in_section)(line.strip())
                except AttributeError:
                    pass  # Skip unsupported section
        return self.object
1006573
def selector_to_str(value)
      return value.value if value.is_a?(Sass::Script::String)
      return unless value.is_a?(Sass::Script::List)

      if value.separator == :comma
        return value.to_a.map do |complex|
          next complex.value if complex.is_a?(Sass::Script::String)
          return unless complex.is_a?(Sass::Script::List) && complex.separator == :space
          return unless (str = selector_to_str(complex))
          str
        end.join(', ')
      end

      value.to_a.map do |compound|
        return unless compound.is_a?(Sass::Script::String)
        compound.value
      end.join(' ')
    end
844028
function translateFormat(formatString, mapping) {
  let len = formatString.length,
    i = 0,
    beginIndex = -1,
    lastChar = null,
    currentChar = "",
    resultString = "";

  for (; i < len; i++) {
    currentChar = formatString.charAt(i);

    if (lastChar === null || lastChar !== currentChar) {
      // change detected
      resultString = _appendMappedString(formatString, mapping, beginIndex, i, resultString);

      beginIndex = i;
    }

    lastChar = currentChar;
  }

  return _appendMappedString(formatString, mapping, beginIndex, i, resultString);
}
1004518
function format(str, formats) {
	let cachedFormats = formats;

	if (!Ember.isArray(cachedFormats) || arguments.length > 2) {
		cachedFormats = new Array(arguments.length - 1);

		for (let i = 1, l = arguments.length; i < l; i++) {
			cachedFormats[i - 1] = arguments[i];
		}
	}

	let idx = 0;
	return str.replace(/%@([0-9]+)?/g, function(s, argIndex) {
		argIndex = (argIndex) ? parseInt(argIndex, 10) - 1 : idx++;
		s = cachedFormats[argIndex];
		return (s === null) ? '(null)' : (s === undefined) ? '' : Ember.inspect(s);
	});
}
1172887
function format(string) {
        string = string.toLowerCase().replace(/-(.)?/g, function ($0, $1) {
            return '-' + $1.toUpperCase();
        });

        return string.charAt(0).toUpperCase()
            + string.substring(1);
    }
1013127
private Format getFormat(String desc)
    {

        if (registry != null)
        {
            String name = desc;
            String args = "";
            int i = desc.indexOf(START_FMT);
            if (i > 0)
            {
                name = desc.substring(0, i).trim();
                args = desc.substring(i + 1).trim();
            }
            FormatFactory factory = registry.get(name);
            if (factory != null)
            {
                return factory.getFormat(name, args, getLocale());
            }
        }
        return null;

    }
258634
def pystr(v_str):
    """"""
    assert isinstance(v_str, str)

    if v_str[0] in ("'", '"') and v_str[0] == v_str[-1]:
        quote = v_str[0]
        out = v_str[1:-1]
    else:
        # NOTE: This is non-standard Fortran.
        #       For example, gfortran rejects non-delimited strings.
        quote = None
        out = v_str

    # Replace escaped strings
    if quote:
        out = out.replace(2 * quote, quote)

    return out
652982
public String format(String s)
    {
        for(int i = 0; i < s.length(); i++) {
            if(s.substring(i, i + 1).equals("*") && i > 0)
                if(isOperand(s.substring(i - 1, i), var) && i < s.length() - 1 && s.substring(i + 1, i + 2).equals(var))
                    s = s.substring(0, i) + s.substring(i + 1);
        }

        return s;
    }
677728
def ConvertToWireFormat(self, value):
    """"""
    value = value.encode("utf8")
    return (self.encoded_tag, VarintEncode(len(value)), value)
992813
def submit_string(self):
        """"""
        required = []
        optional = []
        for file_verifier in self.file_verifiers:
            if file_verifier.optional:
                optional.append('[{0}]'.format(file_verifier.filename))
            else:
                required.append(file_verifier.filename)
        return ' '.join(sorted(required) + sorted(optional))
1107768
function processFormat( value, src, dst ) {
  if( !dst.format ) return value;
  try {
    if( !Array.isArray( dst.format ) )
      throw "Must be an array with two elements!";
    var intlFunc = dst.format[0];
    if( typeof intlFunc !== 'function' )
      throw "First element of the array must be a function!";
    var intlId = dst.format[1];
    if( typeof intlId !== 'string' )
      throw "Second element of the array must be a string!";
    return intlFunc( intlId, value );
  }
  catch( ex ) {
    console.error( ex );
    fail(
      "Error in format of link "
        + PropertyManager(src.obj) + "." + src.name
        + " -> "
        + PropertyManager(dst.obj) + "." + dst.name + "!\n"
        + ex
    );
  }
}
56173
function formatValue(value) {
		
		var out;
		var type = util.sType(value);
		
		// if there is a type, check all sub items for types
		if (_.has(value, 'attributes.type') && _.has(value, '$value') && _.keys(value).length === 2) {
			out = util.moRef(value);
		}
		else if (type) {
			if (util.isArray(value)) {
				out = [];
				
				var subtype = type;
				
				if (subtype.match(/^ArrayOf/)) {
					subtype = subtype.replace(/^ArrayOf/, '');

					if (!Array.isArray(_.get(value, subtype)) && value[subtype]) {
						value[subtype] = [value[subtype]];
					}
				}
				
				_.forEach(value[_.keys(value)[1]], function(obj) {
					out.push(formatValue(obj));
				});
			}
			else if (util.isBoolean(value)) {
				
				// check for valid true values, otherwise false
				if (_.includes(['1', 'true'], _.lowerCase(value.$value))) {
					out = true;
				}
				else {
					out = false;
				}
			}
			else if (util.isInt(value)) {
				out = Number(value.$value);
			}
			else if (_.has(value, '$value')) {
				out = value.$value;
			}
			else {
				out = formatValue(_.omit(value, 'attributes'));
			}
			
		}
		else if (Array.isArray(value)) {
			out = [];
			_.forEach(value, function(val) {
				if (util.sType(val) || util.isArray(val) || util.hasKeys(val)) {
					out.push(formatValue(val));
				}
				else {
					out.push(cast(val));
				}
			});
		}
		else if (util.hasKeys(value)) {
			out = {};
			_.forEach(value, function(val, key) {
				if (util.sType(val) || util.isArray(val) || util.hasKeys(val)) {
					out[key] = formatValue(val);
				}
				else {
					out[key] = cast(val);
				}
			});
		}
		else {
			out = cast(value);
		}
		return out;
	}
198832
def _pad_string(self, str, colwidth):
        """"""
        width = self._disp_width(str)
        prefix = (colwidth - 1 - width) // 2
        suffix = colwidth - prefix - width
        return ' ' * prefix + str + ' ' * suffix