String version. Set space=True to line them all up nicely.
771407
def str(self, space=False):
    """"""
    return "%s/%s (%s)" % (str(int(self.id)).rjust(space and 4),
                           self.name.ljust(space and 50),
                           "; ".join(str(a) for a in self.args))
876925
def leading_whitespace(self, inputstring):
        """"""
        count = 0
        for i, c in enumerate(inputstring):
            if c == " ":
                count += 1
            elif c == "\t":
                count += tabworth - (i % tabworth)
            else:
                break
            if self.indchar is None:
                self.indchar = c
            elif c != self.indchar:
                self.strict_err_or_warn("found mixing of tabs and spaces", inputstring, i)
        return count
1264360
private static String wrapLine(String str, int wrapTextLength) {
	int wtl = wrapTextLength;

	if (str.length() <= wtl) return str;

	String sub = str.substring(0, wtl);
	String rest = str.substring(wtl);
	char firstR = rest.charAt(0);
	String ls = SystemUtil.getOSSpecificLineSeparator();

	if (firstR == ' ' || firstR == '\t') return sub + ls + wrapLine(rest.length() > 1 ? rest.substring(1) : "", wrapTextLength);

	int indexSpace = sub.lastIndexOf(' ');
	int indexTab = sub.lastIndexOf('\t');
	int index = indexSpace <= indexTab ? indexTab : indexSpace;

	if (index == -1) return sub + ls + wrapLine(rest, wrapTextLength);
	return sub.substring(0, index) + ls + wrapLine(sub.substring(index + 1) + rest, wrapTextLength);

    }
840461
def normalize(string: str) -> str:
    
    string = string.replace("\t", "    ")
    lines = string.split("\n")
    while lines and (not lines[0] or lines[0].isspace()):
        lines.pop(0)
    while lines and (not lines[-1] or lines[-1].isspace()):
        lines.pop()
    for i, line in enumerate(lines):
        lines[i] = line.rstrip()
    string = "\n".join(lines)
    string = textwrap.dedent(string)
    return string
514419
def pretty_str(self, indent=0):
        
        spaces = ' ' * indent
        pretty = spaces + 'try:\n'
        pretty += self.body.pretty_str(indent=indent + 2)
        for block in self.catches:
            pretty += '\n' + block.pretty_str(indent)
        if len(self.finally_body) > 0:
            pretty += '\n{}finally:\n'.format(spaces)
            pretty += self.finally_body.pretty_str(indent=indent + 2)
        return pretty
721716
private void setString(String s) {
        _string.setLength(0);
        _string.append(s);
        _length = s.length();
    }
617639
private String generateSpaces(int count) {
        String spaces = "";
        for (int i = 0; i < count; i++) {
            spaces += " ";
        }
        return spaces;
    }
375365
def wrap(self, string, width):
        
        if not string or width <= 0:
            logging.error("invalid string: %s or width: %s" % (string, width))
            return False

        tmp = ""
        for line in string.splitlines():
            if len(line) <= width:
                tmp += line + "\n"
                continue

            cur = 0
            length = len(line)
            while cur + width < length:
                cur = line[:cur+width].rfind(self.sep) + len(self.sep) - 1
                line = line[:cur] + "\n" + line[cur+1:]

            tmp += line + "\n\n"

        return tmp
75959
def pad(string, width, options={})
      supported = [:left, :right, :center]
      padder = options[:padder] || ' '
      align  = options[:align] || :left

      chars = string.to_s.chars.to_a
      if chars.length < width
        string = case :"#{align}"
        when :left
          string + (padder * (width - chars.length))
        when :right
          (padder * (width - chars.length)) + string
        when :center
          right = ((pad_length = width - chars.length).to_f / 2).ceil
          left = pad_length - right
          (padder * left) + string + (padder * right)
        else
          raise ArgumentError, "Alignment must be one of: #{supported.join(' ')}"
        end
      end
      string
    end
704427
function applyInlineFormat(space) {
        var selection, dom, rng, container, offset, startOffset, text, patternRng, pattern, delta, format;

        function splitContainer() {
          // Split text node and remove start/end from text node
          container = container.splitText(startOffset);
          container.splitText(offset - startOffset - delta);
          container.deleteData(0, pattern.start.length);
          container.deleteData(container.data.length - pattern.end.length, pattern.end.length);
        }

        selection = editor.selection;
        dom = editor.dom;

        if (!selection.isCollapsed()) {
          return;
        }

        rng = selection.getRng(true);
        container = rng.startContainer;
        offset = rng.startOffset;
        text = container.data;
        delta = space ? 1 : 0;

        if (container.nodeType != 3) {
          return;
        }

        // Find best matching end
        pattern = findEndPattern(text, offset, delta);
        if (!pattern) {
          return;
        }

        // Find start of matched pattern
        // TODO: Might need to improve this if there is nested formats
        startOffset = Math.max(0, offset - delta);
        startOffset = text.lastIndexOf(pattern.start, startOffset - pattern.end.length - 1);

        if (startOffset === -1) {
          return;
        }

        // Setup a range for the matching word
        patternRng = dom.createRng();
        patternRng.setStart(container, startOffset);
        patternRng.setEnd(container, offset - delta);
        pattern = findPattern(patternRng.toString());

        if (!pattern || !pattern.end) {
          return;
        }

        // If container match doesn't have anything between start/end then do nothing
        if (container.data.length <= pattern.start.length + pattern.end.length) {
          return;
        }

        format = editor.formatter.get(pattern.format);
        if (format && format[0].inline) {
          splitContainer();
          editor.formatter.apply(pattern.format, {}, container);
          return container;
        }
      }
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
386080
public String tabsToSpaces(String string)
    {
        int iOffset = 0;
        for (int i = 0; i < string.length(); i++)
        {
            if (string.charAt(i) == '\n')
                iOffset = i + 1;
            if (string.charAt(i) == '\t')
            {
                int iSpaces = (i - iOffset) % 4;
                if (iSpaces == 0)
                    iSpaces = 4;
                string = string.substring(0, i) + FOUR_SPACES.substring(0, iSpaces) + string.substring(i + 1);
            }
        }
        return string;
    }
1324430
def indent_text(string, indent_level=2):
    """"""
    indented_lines = []

    indent_spaces = ' ' * indent_level

    for line in string.split('\n'):
        indented_lines.append(indent_spaces + line)

    return '\n'.join(indented_lines)
973821
public void skipWhitespace() {
        while (position < string.length()) {
            final char c = string.charAt(position);
            if (c == ' ' || c == '\n' || c == '\r' || c == '\t') {
                position++;
            } else {
                break;
            }
        }
    }
1152988
def pretty_str(self, indent=0):
        
        spaces = ' ' * indent
        pretty = '{}({})' if self.parenthesis else '{}{}'
        name = ('{}.{}'.format(self.field_of.pretty_str(), self.name)
                if self.field_of else self.name)
        return pretty.format(spaces, name)
765095
def prettyln(text, fill='-', align='^', prefix='[ ', suffix=' ]', length=69):
    """"""
    text = '{prefix}{0}{suffix}'.format(text, prefix=prefix, suffix=suffix)
    print(
        "{0:{fill}{align}{length}}".format(
            text, fill=fill, align=align, length=length
        )
    )
114171
def indentsize(line):
    """"""
    expline = string.expandtabs(line)
    return len(expline) - len(string.lstrip(expline))