Miscellany of text-munging functions.

Function stringyString Expansive string formatting for sequence types.
Function isMultiline Returns True if this string has a newline in it.
Function endsInNewline Returns True if this string ends in a newline.
Function greedyWrap Given a string and a column width, return a list of lines.
Function removeLeadingBlanks Undocumented
Function removeLeadingTrailingBlanks Undocumented
Function splitQuoted Like a string split, but don't break substrings inside quotes.
Function strFile Find whether string p occurs in a read()able object f.
def 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 separate lines, and nested sequences have nested indentation.

def isMultiline(s):

Returns True if this string has a newline in it.

def endsInNewline(s):

Returns True if this string ends in a newline.

def 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.

def removeLeadingBlanks(lines):
Undocumented
def removeLeadingTrailingBlanks(s):
Undocumented
def splitQuoted(s):

Like a 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.

def strFile(p, f, caseSensitive=True):

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

Returns (type: bool)
API Documentation for twisted, generated by pydoctor at 2020-03-25 17:34:30.