Package twisted :: Package python :: Module text

[frames | no frames]

## Module twisted.python.text

Miscellany of text-munging functions.

Function Summary
| ``docstringLStrip`(docstring)` Gets rid of unsightly lefthand docstring whitespace residue.
| ``endsInNewline`(s)` Returns True if this string ends in a newline.
| ``greedyWrap`(inString, width)` Given a string and a column width, return a list of lines.
| ``isMultiline`(s)` Returns True if this string has a newline in it.
| `removeLeadingBlanks(lines)`
| `removeLeadingTrailingBlanks(s)`
| ``splitQuoted`(s)` Like string.split, but don't break substrings inside quotes.
`bool` | ``strFile`(p, f, caseSensitive)` Find whether string p occurs in a read()able object f
| ``stringyString`(object, indentation)` Expansive string formatting for sequence types.
| ``wordWrap`(inString, width)` Given a string and a column width, return a list of lines.

Function Details

### docstringLStrip(docstring)

Gets rid of unsightly lefthand docstring whitespace residue.

You'd think someone would have done this already, but apparently not in 1.5.2.

BUT since we're all using Python 2.1 now, use `inspect.getdoc` instead. This function should go away soon.

### endsInNewline(s)

Returns True if this string ends in a newline.

### greedyWrap(inString, width=80)

Given a string and a column width, return a list of lines.

Caveat: I'm use a stupid greedy word-wrapping algorythm. I won't put two spaces at the end of a sentence. I don't do full justification. And no, I've never even *heard* of hypenation.

### isMultiline(s)

Returns True if this string has a newline in it.

### splitQuoted(s)

Like string.split, but don't break substrings inside quotes.

    >>> splitQuoted('the "hairy monkey" likes pie')
    ['the', 'hairy monkey', 'likes', 'pie']

Another one of those "someone must have a better solution for this" things. This implementation is a VERY DUMB hack done too quickly.

### strFile(p, f, caseSensitive=1)

Find whether string p occurs in a read()able object f

  Returns:
    `bool`

### stringyString(object, indentation='')

Expansive string formatting for sequence types.

list.__str__ and dict.__str__ use repr() to display their elements. This function also turns these sequence types into strings, but uses str() on their elements instead.

Sequence elements are also displayed on seperate lines, and nested sequences have nested indentation.

### wordWrap(inString, width=80)

Given a string and a column width, return a list of lines.

Caveat: I'm use a stupid greedy word-wrapping algorythm. I won't put two spaces at the end of a sentence. I don't do full justification. And no, I've never even *heard* of hypenation.

Generated by Epydoc 2.0 on Sat May 15 20:07:42 2004 | http://epydoc.sf.net