6 import os, sys, string, time, getopt
9 def WordWrap(text, cols=70, detect_paragraphs = 0, is_header = 0):
10 text = string.replace(text,
"\r\n",
"\n")
12 if matchobj.group(1) !=
' ' and matchobj.group(2) !=
' ':
17 return matchobj.group(1) + repl_with + matchobj.group(2)
20 text = re.sub(
"([^\n])\n([^\n])",nlrepl,text)
29 r = string.find(text,
"\n", i, i+cols)
32 j = string.rfind(text,
" ", i, i+cols)
34 r = string.find(text,
"\n", i+cols)
36 j = string.find(text,
" ", i+cols)
42 body.append(string.strip(text[i:j]))
46 body = string.join(body,
"\n ")
48 body = string.join(body,
"\n")
def WordWrap(text, cols=70, detect_paragraphs=0, is_header=0)