[Zope-Checkins] CVS: Zope/lib/python/StructuredText - ClassicDocumentClass.py:1.24 ClassicStructuredText.py:1.5
Andreas Jung
andreas@digicool.com
Mon, 11 Mar 2002 10:24:41 -0500
Update of /cvs-repository/Zope/lib/python/StructuredText
In directory cvs.zope.org:/tmp/cvs-serv13122
Modified Files:
ClassicDocumentClass.py ClassicStructuredText.py
Log Message:
string module free zone
=== Zope/lib/python/StructuredText/ClassicDocumentClass.py 1.23 => 1.24 ===
import re, ST, STDOM
-from string import split, join, replace, expandtabs, strip, find
from STletters import letters
StringType=type('')
@@ -25,7 +24,7 @@
t=[]; a=t.append
for s in subs: a(s.getNodeValue())
apply(ST.StructuredTextParagraph.__init__,
- (self, join(t,'\n\n'), ()),
+ (self, '\n\n'.join(t), ()),
kw)
def getColorizableTexts(self): return ()
@@ -374,15 +373,15 @@
rows = []
# initial split
- for row in split(text,"\n"):
+ for row in text.split("\n"):
rows.append(row)
# clean up the rows
for index in range(len(rows)):
tmp = []
- rows[index] = strip(rows[index])
+ rows[index] = rows[index].strip()
l = len(rows[index])-2
- result = split(rows[index][:l],"||")
+ result = rows[index][:l].split("||")
for text in result:
if text:
tmp.append(text)
@@ -462,7 +461,7 @@
if not d: return None
start, end = d.span()
title=top[:start]
- if find(title, '\n') >= 0: return None
+ if title.find('\n') >= 0: return None
if not nb(title): return None
d=top[start:end]
top=top[end:]
@@ -483,16 +482,16 @@
subs=paragraph.getSubparagraphs()
if not subs: return None
top=paragraph.getColorizableTexts()[0]
- if not strip(top): return None
+ if not top.strip(): return None
if top[-2:]=='::':
subs=StructuredTextExample(subs)
- if strip(top)=='::': return subs
+ if top.strip()=='::': return subs
return ST.StructuredTextParagraph(top[:-1],
[subs],
indent=paragraph.indent,
level=paragraph.level)
- if find(top,'\n') >= 0: return None
+ if top.find('\n') >= 0: return None
return StructuredTextSection(top, subs, indent=paragraph.indent, level=paragraph.level)
def doc_literal(
@@ -602,7 +601,7 @@
start,e = r.span(1)
name = s[start:e]
- name = replace(name,'"','',2)
+ name = name.replace('"','',2)
#start = start + 1
st,end = r.span(3)
if punctuation(s[end-1:end]):
=== Zope/lib/python/StructuredText/ClassicStructuredText.py 1.4 => 1.5 ===
import regex
from ts_regex import gsub
-from string import split, join, strip, find
import string,re
@@ -162,11 +161,11 @@
def indent(aString, indent=2):
"""Indent a string the given number of spaces"""
- r=split(untabify(aString),'\n')
+ r=untabify(aString).split('\n')
if not r: return ''
if not r[-1]: del r[-1]
tab=' '*indent
- return "%s%s\n" % (tab,join(r,'\n'+tab))
+ return "%s%s\n" % (tab,('\n'+tab).join(r))
def reindent(aString, indent=2, already_untabified=0):
"reindent a block of text, so that the minimum indent is as given"
@@ -182,12 +181,12 @@
if indent > l:
tab=' ' * (indent-l)
- for s in split(aString,'\n'): append(tab+s)
+ for s in aString.split('\n'): append(tab+s)
else:
l=l-indent
- for s in split(aString,'\n'): append(s[l:])
+ for s in aString.split('\n'): append(s[l:])
- return join(r,'\n')
+ return '\n'.join(r)
def indent_level(aString,
indent_space=ts_regex.compile('\n\( *\)').search_group,
@@ -242,7 +241,7 @@
'''parses a table and returns nested list representing the
table'''
self.table=[]
- text=filter(None,split(aPar,'\n'))
+ text=filter(None,aPar.split('\n'))
for line in text:
row=[]
while 1:
@@ -268,8 +267,8 @@
else:
htmlrow.append(self.CELL%(colspan,cell))
colspan=1
- htmltable.append(self.ROW%join(htmlrow,''))
- return self.TABLE%join(htmltable,'')
+ htmltable.append(self.ROW % ''.join(htmlrow))
+ return self.TABLE % ''.join(htmltable)
table=Table()
@@ -312,7 +311,7 @@
aStructuredString = p_reg.sub(r'<a href="\2">\1</a>\3 ' , aStructuredString)
- protoless = find(aStructuredString, '<a href=":')
+ protoless = aStructuredString.find('<a href=":')
if protoless != -1:
aStructuredString = re.sub('<a href=":', '<a href="',
aStructuredString)
@@ -373,12 +372,12 @@
return s
def ul(self, before, p, after):
- if p: p="<p>%s</p>" % strip(ctag(p))
+ if p: p="<p>%s</p>" % ctag(p).strip()
return ('%s<ul><li>%s\n%s\n</li></ul>\n'
% (before,p,after))
def ol(self, before, p, after):
- if p: p="<p>%s</p>" % strip(ctag(p))
+ if p: p="<p>%s</p>" % ctag(p).strip()
return ('%s<ol><li>%s\n%s\n</li></ol>\n'
% (before,p,after))
@@ -389,9 +388,9 @@
def head(self, before, t, level, d):
if level > 0 and level < 6:
return ('%s<h%d>%s</h%d>\n%s\n'
- % (before,level,strip(ctag(t)),level,d))
+ % (before,level,ctag(t).strip(),level,d))
- t="<p><strong>%s</strong></p>" % strip(ctag(t))
+ t="<p><strong>%s</strong></p>" % ctag(t).strip()
return ('%s<dl><dt>%s\n</dt><dd>%s\n</dd></dl>\n'
% (before,t,d))
@@ -540,7 +539,7 @@
s=str(html_with_references(s))
if s[:4]=='<h1>':
- t=s[4:find(s,'</h1>')]
+ t=s[4: s.find('</h1>')]
s='''<html><head><title>%s</title>
</head><body>
%s