[Zope-Checkins] CVS: Zope/lib/python/Interface - pprint.py:1.6
Andreas Jung
andreas@digicool.com
Thu, 7 Feb 2002 13:00:19 -0500
Update of /cvs-repository/Zope/lib/python/Interface
In directory cvs.zope.org:/tmp/cvs-serv23915/Interface
Modified Files:
pprint.py
Log Message:
replace string module calls by string methods
=== Zope/lib/python/Interface/pprint.py 1.5 => 1.6 ===
""" Pretty-Print an Interface object as structured text (Yum) """
+import string
def trim_doc_string(text):
"""
Trims a doc string to make it format
correctly with structured text.
"""
- text=string.strip(text)
- text=string.replace(text, '\r\n', '\n')
- lines=string.split(text, '\n')
+ text=text.strip()
+ text=text.replace('\r\n', '\n')
+ lines=text.split('\n')
nlines=[lines[0]]
if len(lines) > 1:
min_indent=None
for line in lines[1:]:
- indent=len(line) - len(string.lstrip(line))
+ indent=len(line) - len(line.lstrip())
if indent < min_indent or min_indent is None:
min_indent=indent
for line in lines[1:]:
nlines.append(line[min_indent:])
- return string.join(nlines, '\n')
+ return '\n'.join(nlines, '\n')
@@ -31,25 +31,25 @@
if munge:
line = " " * level
- text = string.split(string.strip(string.translate(text, string.maketrans("\r\n", " "))))
+ text = (string.translate(text, string.maketrans("\r\n", " "))).strip.split()
for word in text:
- line = string.join([line, word])
+ line = ''.join([line, word])
if len(line) > width:
lines.append(line)
line = " " * level
else:
lines.append(line)
- return string.join(lines, "\n")
+ return '\n'.join(lines)
else:
- text = string.split(string.replace(text,"\r\n", "\n"), "\n")
+ text = text.replace("\r\n", "\n").split( "\n")
for line in text:
lines.append( (" " * level) + line)
- return string.join(lines, "\n")
+ return '\n'.join(lines)
def interface_as_stx(I, munge=0):