[Zope-Checkins] CVS: Zope/lib/python/StructuredText - DocumentClass.py:1.46 HTMLWithImages.py:1.7 ST.py:1.16 STDOM.py:1.5 StructuredText.py:1.48 Zwiki.py:1.6
Andreas Jung
andreas@digicool.com
Mon, 11 Mar 2002 10:13:36 -0500
Update of /cvs-repository/Zope/lib/python/StructuredText
In directory cvs.zope.org:/tmp/cvs-serv9922
Modified Files:
DocumentClass.py HTMLWithImages.py ST.py STDOM.py
StructuredText.py Zwiki.py
Log Message:
string module free zone
=== Zope/lib/python/StructuredText/DocumentClass.py 1.45 => 1.46 ===
import re, ST, STDOM
-from string import split, join, replace, expandtabs, strip, find, rstrip
from STletters import letters, digits, literal_punc, under_punc,\
strongem_punc, phrase_delimiters,dbl_quoted_punc
@@ -36,7 +35,7 @@
for s in subs:
flatten(s, a)
apply(ST.StructuredTextParagraph.__init__,
- (self, join(t,'\n\n'), ()),
+ (self, '\n\n'.join(t), ()),
kw)
def getColorizableTexts(self): return ()
@@ -473,12 +472,12 @@
col = re.compile('\|').search
innertable = re.compile('\|([-]+|[=]+)\|').search
- text = strip(text)
- rows = split(text,'\n')
+ text = text.strip()
+ rows = text.split('\n')
foo = ""
for row in range(len(rows)):
- rows[row] = strip(rows[row])
+ rows[row] = rows[row].strip()
# have indexes store if a row is a divider
# or a cell part
@@ -496,14 +495,14 @@
ignore = [] # reset ignore
#continue # skip dividers
- tmp = strip(rows[index]) # clean the row up
+ tmp = rows[index].strip() # clean the row up
tmp = tmp[1:len(tmp)-1] # remove leading + trailing |
offset = 0
# find the start and end of inner
# tables. ignore everything between
if innertable(tmp):
- tmpstr = strip(tmp)
+ tmpstr = tmp.strip()
while innertable(tmpstr):
start,end = innertable(tmpstr).span()
if not (start,end-1) in ignore:
@@ -640,30 +639,30 @@
left = []
right = []
text = row[index][0]
- text = split(text,'\n')
+ text = text.split('\n')
text = text[:len(text)-1]
align = ""
valign = ""
for t in text:
- t = strip(t)
+ t = t.strip()
if not t:
topindent = topindent + 1
else:
break
text.reverse()
for t in text:
- t = strip(t)
+ t = t.strip()
if not t:
bottomindent = bottomindent + 1
else:
break
text.reverse()
- tmp = join(text[topindent:len(text)-bottomindent],"\n")
+ tmp = '\n'.join(text[topindent:len(text)-bottomindent])
pars = re.compile("\n\s*\n").split(tmp)
for par in pars:
if index > 0:
par = par[1:]
- par = split(par, ' ')
+ par = par.split(' ')
for p in par:
if not p:
leftindent = leftindent+1
@@ -756,7 +755,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:]
@@ -775,17 +774,17 @@
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
# copy attrs when returning a paragraph
kw = {}
atts = getattr(paragraph, '_attributes', [])
for att in atts: kw[att] = getattr(paragraph, att)
return apply(ST.StructuredTextParagraph, (top[:-1], [subs]), kw)
- if find(top,'\n') >= 0: return None
+ if top.find('\n') >= 0: return None
return StructuredTextSection(top, subs, indent=paragraph.indent)
def doc_literal(
@@ -908,7 +907,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/HTMLWithImages.py 1.6 => 1.7 ===
##############################################################################
-from string import join, split, find
-import re, sys, ST
from HTMLClass import HTMLClass
@@ -46,10 +44,3 @@
def xref(self, doc, level, output):
val = doc.getNodeValue()
output('<a href="#ref%s">[%s]</a>' % (val, val) )
-
-
-
-
-
-
-
=== Zope/lib/python/StructuredText/ST.py 1.15 => 1.16 ===
import re, STDOM
-from string import split, join, replace, expandtabs, strip, find
#####################################################################
# Updated functions #
@@ -123,10 +122,10 @@
struct = [] # the structure to be returned
run = struct
- paragraphs = expandtabs(paragraphs)
+ paragraphs = paragraphs.expandtabs()
paragraphs = '%s%s%s' % ('\n\n', paragraphs, '\n\n')
paragraphs = delimiter.split(paragraphs)
- paragraphs = filter(strip, paragraphs)
+ paragraphs = [ x for x in paragraphs if x.strip() ]
if not paragraphs: return StructuredTextDocument()
@@ -226,7 +225,7 @@
)
for p in self._subs: a(`p`)
a((' '*(self.indent or 0))+'])')
- return join(r,'\n')
+ return '\n'.join(r)
"""
create aliases for all above functions in the pythony way.
@@ -282,7 +281,7 @@
a('%s([' % self.__class__.__name__)
for p in self._subs: a(`p`+',')
a('])')
- return join(r,'\n')
+ return '\n'.join(r)
"""
create aliases for all above functions in the pythony way.
=== Zope/lib/python/StructuredText/STDOM.py 1.4 => 1.5 ===
All standard Zope objects support DOM to a limited extent.
"""
-import string
-
# Node type codes
# ---------------
@@ -415,7 +413,7 @@
if type(c) is not st:
c=c.getNodeValue()
r.append(c)
- return string.join(r,'')
+ return ''.join(r)
def getParentNode(self):
"""
=== Zope/lib/python/StructuredText/StructuredText.py 1.47 => 1.48 ===
from ST import Basic
-import re, string,sys
+import re, sys
from STletters import letters
Document = DocumentClass.DocumentClass()
=== Zope/lib/python/StructuredText/Zwiki.py 1.5 => 1.6 ===
from Html import HTML
-from string import split
from ST import DOC
import re