Commit cdb2ae91 authored by Andreas Jung's avatar Andreas Jung

string module free zone

parent 6b1aa57d
......@@ -12,7 +12,6 @@
##############################################################################
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 @@ class StructuredTextExample(ST.StructuredTextParagraph):
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 @@ class DocumentClass:
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 @@ class DocumentClass:
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 @@ class DocumentClass:
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 @@ class DocumentClass:
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 @@ class DocumentClass:
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 @@ class DocumentClass:
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]):
......
......@@ -11,8 +11,6 @@
#
##############################################################################
from string import join, split, find
import re, sys, ST
from HTMLClass import HTMLClass
......@@ -46,10 +44,3 @@ class HTMLWithImages(HTMLClass):
def xref(self, doc, level, output):
val = doc.getNodeValue()
output('<a href="#ref%s">[%s]</a>' % (val, val) )
......@@ -12,7 +12,6 @@
##############################################################################
import re, STDOM
from string import split, join, replace, expandtabs, strip, find
#####################################################################
# Updated functions #
......@@ -123,10 +122,10 @@ def StructuredText(paragraphs, delimiter=re.compile(para_delim)):
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 @@ class StructuredTextParagraph(STDOM.Element):
)
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 @@ class StructuredTextDocument(StructuredTextParagraph):
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.
......
......@@ -15,8 +15,6 @@ DOM implementation in StructuredText : Read-Only methods
All standard Zope objects support DOM to a limited extent.
"""
import string
# Node type codes
# ---------------
......@@ -415,7 +413,7 @@ class Element(Node):
if type(c) is not st:
c=c.getNodeValue()
r.append(c)
return string.join(r,'')
return ''.join(r)
def getParentNode(self):
"""
......
......@@ -19,7 +19,7 @@ import HTMLClass, DocumentClass, ClassicDocumentClass
import DocumentWithImages, HTMLWithImages
from ST import Basic
import re, string,sys
import re, sys
from STletters import letters
Document = DocumentClass.DocumentClass()
......
......@@ -13,7 +13,6 @@
##############################################################################
from Html import HTML
from string import split
from ST import DOC
import re
......
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