Commit 32635b7d authored by Andreas Jung's avatar Andreas Jung

replace string module calls by string methods

parent ae630f47
import string
""" 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 @@ def justify_and_indent(text, level, munge=0, width=72):
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):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment