Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docstring/StructuredText
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9045/happydoclib/docstring/StructuredText
Modified Files:
ClassicDocumentClass.py ClassicStructuredText.py
DocumentClass.py ST.py STDOM.py StructuredText.py Zwiki.py
__init__.py ts_regex.py
Log Message:
Update the StructuredText parser.
Index: ClassicDocumentClass.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docstring/StructuredText/ClassicDocumentClass.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** ClassicDocumentClass.py 17 Nov 2002 00:26:19 -0000 1.1.1.1
--- ClassicDocumentClass.py 16 Apr 2006 23:22:21 -0000 1.2
***************
*** 15,20 ****
from STletters import letters
! StringType=type('')
! ListType=type([])
class StructuredTextExample(ST.StructuredTextParagraph):
--- 15,20 ----
from STletters import letters
! from types import StringType, UnicodeType, ListType
! StringTypes = (StringType, UnicodeType)
class StructuredTextExample(ST.StructuredTextParagraph):
***************
*** 24,30 ****
t=[]; a=t.append
for s in subs: a(s.getNodeValue())
! apply(ST.StructuredTextParagraph.__init__,
! (self, '\n\n'.join(t), ()),
! kw)
def getColorizableTexts(self): return ()
--- 24,28 ----
t=[]; a=t.append
for s in subs: a(s.getNodeValue())
! ST.StructuredTextParagraph.__init__(self, '\n\n'.join(t), (), **kw)
def getColorizableTexts(self): return ()
***************
*** 47,51 ****
def __init__(self, title, src, subs, **kw):
! apply(ST.StructuredTextParagraph.__init__, (self, src, subs), kw)
self._title=title
--- 45,49 ----
def __init__(self, title, src, subs, **kw):
! ST.StructuredTextParagraph.__init__(self, src, subs, **kw)
self._title=title
***************
*** 63,69 ****
"""Represents a section of a document with a title and a body"""
def __init__(self, src, subs=None, **kw):
! apply(ST.StructuredTextParagraph.__init__,
! (self, StructuredTextSectionTitle(src), subs),
! kw)
def getColorizableTexts(self):
--- 61,66 ----
"""Represents a section of a document with a title and a body"""
def __init__(self, src, subs=None, **kw):
! ST.StructuredTextParagraph.__init__(
! self, StructuredTextSectionTitle(src), subs, **kw)
def getColorizableTexts(self):
***************
*** 83,87 ****
def __init__(self, rows, src, subs, **kw):
! apply(ST.StructuredTextDocument.__init__,(self,subs),kw)
self._rows = []
for row in rows:
--- 80,84 ----
def __init__(self, rows, src, subs, **kw):
! ST.StructuredTextDocument.__init__(self, subs, **kw)
self._rows = []
for row in rows:
***************
*** 139,143 ****
[('this is column one',1), ('this is column two',1)]
"""
! apply(ST.StructuredTextDocument.__init__,(self,[]),kw)
self._columns = []
for column in row:
--- 136,140 ----
[('this is column one',1), ('this is column two',1)]
"""
! ST.StructuredTextDocument.__init__(self, [], **kw)
self._columns = []
for column in row:
***************
*** 159,163 ****
def __init__(self,text,span,kw):
! apply(ST.StructuredTextParagraph.__init__,(self,text,[]),kw)
self._span = span
--- 156,160 ----
def __init__(self,text,span,kw):
! ST.StructuredTextParagraph.__init__(self, text, [], **kw)
self._span = span
***************
*** 236,240 ****
def __call__(self, doc):
! if type(doc) is type(''):
doc=ST.StructuredText(doc)
doc.setSubparagraphs(self.color_paragraphs(
--- 233,237 ----
def __call__(self, doc):
! if type(doc) in StringTypes:
doc=ST.StructuredText(doc)
doc.setSubparagraphs(self.color_paragraphs(
***************
*** 246,250 ****
def parse(self, raw_string, text_type,
! type=type, st=type(''), lt=type([])):
"""
--- 243,247 ----
def parse(self, raw_string, text_type,
! type=type, sts=StringTypes, lt=type([])):
"""
***************
*** 262,266 ****
append=tmp.append
! if type(text_type) is st: text_type=getattr(self, text_type)
while 1:
--- 259,263 ----
append=tmp.append
! if type(text_type) in sts: text_type=getattr(self, text_type)
while 1:
***************
*** 273,277 ****
tt=type(t)
! if tt is st:
# if we get a string back, add it to text to be parsed
raw_string = t+raw_string[end:len(raw_string)]
--- 270,274 ----
tt=type(t)
! if tt in sts:
# if we get a string back, add it to text to be parsed
raw_string = t+raw_string[end:len(raw_string)]
***************
*** 300,309 ****
for text_type in types:
! if type(str) is StringType:
str = self.parse(str, text_type)
elif type(str) is ListType:
r=[]; a=r.append
for s in str:
! if type(s) is StringType:
s=self.parse(s, text_type)
if type(s) is ListType: r[len(r):]=s
--- 297,306 ----
for text_type in types:
! if type(str) in StringTypes:
str = self.parse(str, text_type)
elif type(str) is ListType:
r=[]; a=r.append
for s in str:
! if type(s) in StringTypes:
s=self.parse(s, text_type)
if type(s) is ListType: r[len(r):]=s
***************
*** 328,332 ****
def color_paragraphs(self, raw_paragraphs,
type=type, sequence_types=(type([]), type(())),
! st=type('')):
result=[]
for paragraph in raw_paragraphs:
--- 325,329 ----
def color_paragraphs(self, raw_paragraphs,
type=type, sequence_types=(type([]), type(())),
! sts=StringTypes):
result=[]
for paragraph in raw_paragraphs:
***************
*** 337,341 ****
for pt in self.paragraph_types:
! if type(pt) is st:
# grab the corresponding function
pt=getattr(self, pt)
--- 334,338 ----
for pt in self.paragraph_types:
! if type(pt) in sts:
# grab the corresponding function
pt=getattr(self, pt)
Index: ClassicStructuredText.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docstring/StructuredText/ClassicStructuredText.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** ClassicStructuredText.py 17 Nov 2002 00:26:20 -0000 1.1.1.1
--- ClassicStructuredText.py 16 Apr 2006 23:22:21 -0000 1.2
***************
*** 135,141 ****
import ts_regex
! import regex
! from ts_regex import gsub
! import string,re
--- 135,139 ----
import ts_regex
! import string, re
***************
*** 232,238 ****
class Table:
! CELL=' <TD ALIGN=CENTER COLSPAN=%i>%s</TD>\n'
! ROW=' <TR>\n%s </TR>\n'
! TABLE='\n<TABLE BORDER=1 CELLPADDING=2>\n%s</TABLE>'
def create(self,aPar,
td_reg=re.compile(r'[ \t\n]*\|\|([^\0|]*)')
--- 230,236 ----
class Table:
! CELL=' <td align="center" colspan="%i">%s</td>\n'
! ROW=' <tr>\n%s </tr>\n'
! TABLE='\n<table border="1" cellpadding="2">\n%s</table>'
def create(self,aPar,
td_reg=re.compile(r'[ \t\n]*\|\|([^\0|]*)')
***************
*** 283,287 ****
def __init__(self, aStructuredString, level=0,
! paragraph_divider=regex.compile('\(\r?\n *\)+\r?\n'),
):
'''Convert a structured text string into a structured text object.
--- 281,285 ----
def __init__(self, aStructuredString, level=0,
! paragraph_divider=ts_regex.compile('\(\r?\n *\)+\r?\n'),
):
'''Convert a structured text string into a structured text object.
***************
*** 402,409 ****
r=''
else:
! r='<PRE>\n'
for s in structure:
r="%s%s\n\n%s" % (r,html_quote(s[0]),self.pre(s[1],1))
! if not tagged: r=r+'</PRE>\n'
return r
--- 400,407 ----
r=''
else:
! r='<pre>\n'
for s in structure:
r="%s%s\n\n%s" % (r,html_quote(s[0]),self.pre(s[1],1))
! if not tagged: r=r.rstrip()+'\n</pre>\n'
return r
Index: DocumentClass.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docstring/StructuredText/DocumentClass.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** DocumentClass.py 17 Nov 2002 00:26:21 -0000 1.1.1.1
--- DocumentClass.py 16 Apr 2006 23:22:21 -0000 1.2
***************
*** 16,21 ****
strongem_punc, phrase_delimiters,dbl_quoted_punc
! StringType=type('')
! ListType=type([])
def flatten(obj, append):
--- 16,21 ----
strongem_punc, phrase_delimiters,dbl_quoted_punc
! from types import StringType, UnicodeType, ListType
! StringTypes = (StringType, UnicodeType)
def flatten(obj, append):
***************
*** 35,41 ****
for s in subs:
flatten(s, a)
! apply(ST.StructuredTextParagraph.__init__,
! (self, '\n\n'.join(t), ()),
! kw)
def getColorizableTexts(self): return ()
--- 35,39 ----
for s in subs:
flatten(s, a)
! ST.StructuredTextParagraph.__init__(self, '\n\n'.join(t), (), **kw)
def getColorizableTexts(self): return ()
***************
*** 58,62 ****
def __init__(self, title, src, subs, **kw):
! apply(ST.StructuredTextParagraph.__init__, (self, src, subs), kw)
self._title=title
--- 56,60 ----
def __init__(self, title, src, subs, **kw):
! ST.StructuredTextParagraph.__init__(self, src, subs, **kw)
self._title=title
***************
*** 74,80 ****
"""Represents a section of a document with a title and a body"""
def __init__(self, src, subs=None, **kw):
! apply(ST.StructuredTextParagraph.__init__,
! (self, StructuredTextSectionTitle(src), subs),
! kw)
def getColorizableTexts(self):
--- 72,77 ----
"""Represents a section of a document with a title and a body"""
def __init__(self, src, subs=None, **kw):
! ST.StructuredTextParagraph.__init__(
! self, StructuredTextSectionTitle(src), subs, **kw)
def getColorizableTexts(self):
***************
*** 94,98 ****
def __init__(self, rows, src, subs, **kw):
! apply(ST.StructuredTextParagraph.__init__,(self,subs),kw)
self._rows = []
for row in rows:
--- 91,95 ----
def __init__(self, rows, src, subs, **kw):
! ST.StructuredTextParagraph.__init__(self, subs, **kw)
self._rows = []
for row in rows:
***************
*** 150,155 ****
return self.getColorizableTexts()
! def _setColorizableTexts(self):
! return self.setColorizableTexts()
# StructuredTextRow holds StructuredTextColumns
--- 147,152 ----
return self.getColorizableTexts()
! def _setColorizableTexts(self, texts):
! return self.setColorizableTexts(texts)
# StructuredTextRow holds StructuredTextColumns
***************
*** 165,169 ****
"""
! apply(ST.StructuredTextParagraph.__init__,(self,[]),kw)
self._columns = []
--- 162,166 ----
"""
! ST.StructuredTextParagraph.__init__(self, [], **kw)
self._columns = []
***************
*** 198,202 ****
def __init__(self,text,span,align,valign,typ,kw):
! apply(ST.StructuredTextParagraph.__init__,(self,text,[]),kw)
self._span = span
self._align = align
--- 195,199 ----
def __init__(self,text,span,align,valign,typ,kw):
! ST.StructuredTextParagraph.__init__(self, text, [], **kw)
self._span = span
self._align = align
***************
*** 239,245 ****
for k, v in kw.items(): setattr(self, k, v)
! def getChildren(self, type=type, lt=type([])):
v=self._value
! if type(v) is not lt: v=[v]
return v
--- 236,242 ----
for k, v in kw.items(): setattr(self, k, v)
! def getChildren(self):
v=self._value
! if not isinstance(v, ListType): v=[v]
return v
***************
*** 295,306 ****
#'doc_underline'
text_types = [
- #
- # Leave sgml before literal here
- # so that quotable characters embedded
- # in single quotes are NOT escaped.
- # - dhellmann - HappyDoc
- #
- 'doc_sgml',
'doc_literal',
'doc_inner_link',
'doc_named_link',
--- 292,297 ----
#'doc_underline'
text_types = [
'doc_literal',
+ 'doc_sgml',
'doc_inner_link',
'doc_named_link',
***************
*** 315,319 ****
def __call__(self, doc):
! if type(doc) is type(''):
doc=ST.StructuredText(doc)
doc.setSubparagraphs(self.color_paragraphs(
--- 306,310 ----
def __call__(self, doc):
! if type(doc) in StringTypes:
doc=ST.StructuredText(doc)
doc.setSubparagraphs(self.color_paragraphs(
***************
*** 325,329 ****
def parse(self, raw_string, text_type,
! type=type, st=type(''), lt=type([])):
"""
--- 316,320 ----
def parse(self, raw_string, text_type,
! type=type, sts=StringTypes, lt=type([])):
"""
***************
*** 341,345 ****
append=tmp.append
! if type(text_type) is st: text_type=getattr(self, text_type)
while 1:
--- 332,336 ----
append=tmp.append
! if type(text_type) in sts: text_type=getattr(self, text_type)
while 1:
***************
*** 352,356 ****
tt=type(t)
! if tt is st:
# if we get a string back, add it to text to be parsed
raw_string = t+raw_string[end:len(raw_string)]
--- 343,347 ----
tt=type(t)
! if tt in sts:
# if we get a string back, add it to text to be parsed
raw_string = t+raw_string[end:len(raw_string)]
***************
*** 379,388 ****
for text_type in types:
! if type(str) is StringType:
str = self.parse(str, text_type)
elif type(str) is ListType:
r=[]; a=r.append
for s in str:
! if type(s) is StringType:
s=self.parse(s, text_type)
if type(s) is ListType: r[len(r):]=s
--- 370,379 ----
for text_type in types:
! if type(str) in StringTypes:
str = self.parse(str, text_type)
elif type(str) is ListType:
r=[]; a=r.append
for s in str:
! if type(s) in StringTypes:
s=self.parse(s, text_type)
if type(s) is ListType: r[len(r):]=s
***************
*** 407,411 ****
def color_paragraphs(self, raw_paragraphs,
type=type, sequence_types=(type([]), type(())),
! st=type('')):
result=[]
for paragraph in raw_paragraphs:
--- 398,402 ----
def color_paragraphs(self, raw_paragraphs,
type=type, sequence_types=(type([]), type(())),
! sts=StringTypes):
result=[]
for paragraph in raw_paragraphs:
***************
*** 415,419 ****
for pt in self.paragraph_types:
! if type(pt) is st:
# grab the corresponding function
pt=getattr(self, pt)
--- 406,410 ----
for pt in self.paragraph_types:
! if type(pt) in sts:
# grab the corresponding function
pt=getattr(self, pt)
***************
*** 434,439 ****
for att in atts: kw[att] = getattr(paragraph, att)
subs = self.color_paragraphs(paragraph.getSubparagraphs())
! new_paragraphs=apply(ST.StructuredTextParagraph,
! (paragraph.getColorizableTexts()[0], subs), kw),
# color the inline StructuredText types
--- 425,430 ----
for att in atts: kw[att] = getattr(paragraph, att)
subs = self.color_paragraphs(paragraph.getSubparagraphs())
! new_paragraphs=ST.StructuredTextParagraph(
! paragraph. getColorizableTexts()[0], subs, **kw),
# color the inline StructuredText types
***************
*** 789,793 ****
atts = getattr(paragraph, '_attributes', [])
for att in atts: kw[att] = getattr(paragraph, att)
! return apply(ST.StructuredTextParagraph, (top[:-1], [subs]), kw)
if top.find('\n') >= 0: return None
--- 780,784 ----
atts = getattr(paragraph, '_attributes', [])
for att in atts: kw[att] = getattr(paragraph, att)
! return ST.StructuredTextParagraph(top[:-1], [subs], **kw)
if top.find('\n') >= 0: return None
***************
*** 941,944 ****
--- 932,937 ----
text = s[start:end]
return (StructuredTextSGML(text),start,end)
+ else:
+ return None
Index: ST.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docstring/StructuredText/ST.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** ST.py 17 Nov 2002 00:26:21 -0000 1.1.1.1
--- ST.py 16 Apr 2006 23:22:21 -0000 1.2
***************
*** 13,16 ****
--- 13,17 ----
import re, STDOM
+ from types import ListType
#####################################################################
***************
*** 188,194 ****
for k, v in kw.items(): setattr(self, k, v)
! def getChildren(self, type=type, lt=type([])):
src=self._src
! if type(src) is not lt: src=[src]
return src+self._subs
--- 189,195 ----
for k, v in kw.items(): setattr(self, k, v)
! def getChildren(self):
src=self._src
! if not isinstance(src, ListType): src=[src]
return src+self._subs
***************
*** 199,202 ****
--- 200,205 ----
if hasattr(self, name):
return STDOM.Attr(name, getattr(self, name))
+ else:
+ return None
def getAttributes(self):
***************
*** 232,237 ****
"""
! def _get_Children(self, type=type, lt=type([])):
! return self.getChildren(type,lt)
def _get_Attribute(self, name):
--- 235,240 ----
"""
! def _get_Children(self):
! return self.getChildren()
def _get_Attribute(self, name):
***************
*** 264,270 ****
def __init__(self, subs=None, **kw):
! apply(StructuredTextParagraph.__init__,
! (self, '', subs),
! kw)
def getChildren(self):
--- 267,271 ----
def __init__(self, subs=None, **kw):
! StructuredTextParagraph.__init__(self, '', subs, **kw)
def getChildren(self):
Index: STDOM.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docstring/StructuredText/STDOM.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** STDOM.py 17 Nov 2002 00:26:27 -0000 1.1.1.1
--- STDOM.py 16 Apr 2006 23:22:21 -0000 1.2
***************
*** 17,20 ****
--- 17,23 ----
"""
+ from types import StringType, UnicodeType
+ StringTypes = (StringType, UnicodeType)
+
# Node type codes
# ---------------
***************
*** 82,86 ****
"""
! def getChildNodes(self, type=type, st=type('')):
"""
Returns a NodeList that contains all children of this node.
--- 85,89 ----
"""
! def getChildNodes(self, type=type, sts=StringTypes):
"""
Returns a NodeList that contains all children of this node.
***************
*** 90,99 ****
r=[]
for n in self.getChildren():
! if type(n) is st: n=TextNode(n)
r.append(n.__of__(self))
return NodeList(r)
! def getFirstChild(self, type=type, st=type('')):
"""
The first child of this node. If there is no such node
--- 93,102 ----
r=[]
for n in self.getChildren():
! if type(n) in sts: n=TextNode(n)
r.append(n.__of__(self))
return NodeList(r)
! def getFirstChild(self, type=type, sts=StringTypes):
"""
The first child of this node. If there is no such node
***************
*** 107,116 ****
n=children[0]
! if type(n) is st:
n=TextNode(n)
return n.__of__(self)
! def getLastChild(self, type=type, st=type('')):
"""
The last child of this node. If there is no such node
--- 110,119 ----
n=children[0]
! if type(n) in sts:
n=TextNode(n)
return n.__of__(self)
! def getLastChild(self, type=type, sts=StringTypes):
"""
The last child of this node. If there is no such node
***************
*** 119,124 ****
children = self.getChildren()
if not children: return None
! n=chidren[-1]
! if type(n) is st: n=TextNode(n)
return n.__of__(self)
--- 122,127 ----
children = self.getChildren()
if not children: return None
! n=children[-1]
! if type(n) in sts: n=TextNode(n)
return n.__of__(self)
***************
*** 127,138 ****
"""
! def _get_ChildNodes(self, type=type, st=type('')):
! return self.getChildNodes(type,st)
! def _get_FirstChild(self, type=type, st=type('')):
! return self.getFirstChild(type,st)
! def _get_LastChild(self, type=type, st=type('')):
! return self.getLastChild(type,st)
class NodeWrapper(ParentNode):
--- 130,141 ----
"""
! def _get_ChildNodes(self, type=type, sts=StringTypes):
! return self.getChildNodes(type,sts)
! def _get_FirstChild(self, type=type, sts=StringTypes):
! return self.getFirstChild(type,sts)
! def _get_LastChild(self, type=type, sts=StringTypes):
! return self.getLastChild(type,sts)
class NodeWrapper(ParentNode):
***************
*** 166,175 ****
return None
! def getPreviousSibling(self,
! type=type,
! st=type(''),
! getattr=getattr,
! None=None):
!
"""
The node immediately preceding this node. If
--- 169,173 ----
return None
! def getPreviousSibling(self):
"""
The node immediately preceding this node. If
***************
*** 191,195 ****
except IndexError: return None
else:
! if type(n) is st:
n=TextNode(n)
n._DOMIndex=index
--- 189,193 ----
except IndexError: return None
else:
! if type(n) in StringTypes:
n=TextNode(n)
n._DOMIndex=index
***************
*** 197,201 ****
! def getNextSibling(self, type=type, st=type('')):
"""
The node immediately preceding this node. If
--- 195,199 ----
! def getNextSibling(self):
"""
The node immediately preceding this node. If
***************
*** 217,221 ****
return None
else:
! if type(n) is st:
n=TextNode(n)
n._DOMIndex=index
--- 215,219 ----
return None
else:
! if type(n) in StringTypes:
n=TextNode(n)
n._DOMIndex=index
***************
*** 238,251 ****
return self._getDOMIndex(children,getattr)
! def _get_PreviousSibling(self,
! type=type,
! st=type(''),
! getattr=getattr,
! None=None):
!
! return self.getPreviousSibling(type,st,getattr,None)
! def _get_NextSibling(self, type=type, st=type('')):
! return self.getNextSibling(type,st)
def _get_OwnerDocument(self):
--- 236,244 ----
return self._getDOMIndex(children,getattr)
! def _get_PreviousSibling(self):
! return self.getPreviousSibling()
! def _get_NextSibling(self):
! return self.getNextSibling()
def _get_OwnerDocument(self):
***************
*** 289,295 ****
def getPreviousSibling(self,
type=type,
! st=type(''),
! getattr=getattr,
! None=None):
"""
The node immediately preceding this node. If
--- 282,287 ----
def getPreviousSibling(self,
type=type,
! sts=StringTypes,
! getattr=getattr):
"""
The node immediately preceding this node. If
***************
*** 297,301 ****
"""
! def getNextSibling(self, type=type, st=type('')):
"""
The node immediately preceding this node. If
--- 289,293 ----
"""
! def getNextSibling(self, type=type, sts=StringTypes):
"""
The node immediately preceding this node. If
***************
*** 341,353 ****
return self.getChildren()
! def _get_PreviousSibling(self,
! type=type,
! st=type(''),
! getattr=getattr,
! None=None):
!
! return self.getPreviousSibling(type,st,getattr,None)
! def _get_NextSibling(self, type=type, st=type('')):
return self.getNextSibling()
--- 333,340 ----
return self.getChildren()
! def _get_PreviousSibling(self):
! return self.getPreviousSibling()
! def _get_NextSibling(self):
return self.getNextSibling()
***************
*** 408,415 ****
return ELEMENT_NODE
! def getNodeValue(self, type=type, st=type('')):
r=[]
for c in self.getChildren():
! if type(c) is not st:
c=c.getNodeValue()
r.append(c)
--- 395,402 ----
return ELEMENT_NODE
! def getNodeValue(self):
r=[]
for c in self.getChildren():
! if type(c) not in StringTypes:
c=c.getNodeValue()
r.append(c)
***************
*** 481,486 ****
return self.getNodeType()
! def _get_NodeValue(self, type=type, st=type('')):
! return self.getNodeValue(type,st)
def _get_ParentNode(self):
--- 468,473 ----
return self.getNodeType()
! def _get_NodeValue(self):
! return self.getNodeValue()
def _get_ParentNode(self):
***************
*** 518,522 ****
self._data = list or []
! def __getitem__(self, index, type=type, st=type('')):
return self._data[index]
--- 505,509 ----
self._data = list or []
! def __getitem__(self, index, type=type, sts=StringTypes):
return self._data[index]
Index: StructuredText.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docstring/StructuredText/StructuredText.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** StructuredText.py 17 Nov 2002 00:26:27 -0000 1.1.1.1
--- StructuredText.py 16 Apr 2006 23:22:21 -0000 1.2
***************
*** 16,20 ****
! import HTMLClass, DocumentClass, ClassicDocumentClass
import DocumentWithImages, HTMLWithImages
from ST import Basic
--- 16,20 ----
! import HTMLClass, DocumentClass
import DocumentWithImages, HTMLWithImages
from ST import Basic
Index: Zwiki.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docstring/StructuredText/Zwiki.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Zwiki.py 17 Nov 2002 00:26:27 -0000 1.1.1.1
--- Zwiki.py 16 Apr 2006 23:22:21 -0000 1.2
***************
*** 1,3 ****
- #!/usr/bin/python
##############################################################################
#
--- 1,2 ----
Index: __init__.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docstring/StructuredText/__init__.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** __init__.py 17 Nov 2002 00:26:27 -0000 1.1.1.1
--- __init__.py 16 Apr 2006 23:22:21 -0000 1.2
***************
*** 18,22 ****
import DocBookClass
import HTMLWithImages
! from types import StringType
import DocumentWithImages
--- 18,22 ----
import DocBookClass
import HTMLWithImages
! from types import StringType, UnicodeType
import DocumentWithImages
***************
*** 25,29 ****
def HTML(src, level=1):
! if isinstance(src, StringType):
return ClassicHTML(src, level)
return HTMLNG(src, level)
--- 25,29 ----
def HTML(src, level=1):
! if isinstance(src, StringType) or isinstance(src, UnicodeType):
return ClassicHTML(src, level)
return HTMLNG(src, level)
Index: ts_regex.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docstring/StructuredText/ts_regex.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** ts_regex.py 17 Nov 2002 00:26:27 -0000 1.1.1.1
--- ts_regex.py 16 Apr 2006 23:22:21 -0000 1.2
***************
*** 1,85 ****
##############################################################################
! #
! # Zope Public License (ZPL) Version 1.0
! # -------------------------------------
! #
! # Copyright (c) Digital Creations. All rights reserved.
! #
! # This license has been certified as Open Source(tm).
! #
! # Redistribution and use in source and binary forms, with or without
! # modification, are permitted provided that the following conditions are
! # met:
! #
! # 1. Redistributions in source code must retain the above copyright
! # notice, this list of conditions, and the following disclaimer.
! #
! # 2. Redistributions in binary form must reproduce the above copyright
! # notice, this list of conditions, and the following disclaimer in
! # the documentation and/or other materials provided with the
! # distribution.
! #
! # 3. Digital Creations requests that attribution be given to Zope
! # in any manner possible. Zope includes a "Powered by Zope"
! # button that is installed by default. While it is not a license
! # violation to remove this button, it is requested that the
! # attribution remain. A significant investment has been put
! # into Zope, and this effort will continue if the Zope community
! # continues to grow. This is one way to assure that growth.
! #
! # 4. All advertising materials and documentation mentioning
! # features derived from or use of this software must display
! # the following acknowledgement:
! #
! # "This product includes software developed by Digital Creations
! # for use in the Z Object Publishing Environment
! # (http://www.zope.org/)."
! #
! # In the event that the product being advertised includes an
! # intact Zope distribution (with copyright and license included)
! # then this clause is waived.
! #
! # 5. Names associated with Zope or Digital Creations must not be used to
! # endorse or promote products derived from this software without
! # prior written permission from Digital Creations.
! #
! # 6. Modified redistributions of any form whatsoever must retain
! # the following acknowledgment:
! #
! # "This product includes software developed by Digital Creations
! # for use in the Z Object Publishing Environment
! # (http://www.zope.org/)."
! #
! # Intact (re-)distributions of any official Zope release do not
! # require an external acknowledgement.
! #
! # 7. Modifications are encouraged but must be packaged separately as
! # patches to official Zope releases. Distributions that do not
! # clearly separate the patches from the original work must be clearly
! # labeled as unofficial distributions. Modifications which do not
! # carry the name Zope may be packaged in any form, as long as they
! # conform to all of the clauses above.
! #
! #
! # Disclaimer
! #
! # THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
! # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
! # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
! # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
! # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
! # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
! # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
! # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
! # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
! # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! # SUCH DAMAGE.
! #
! #
! # This software consists of contributions made by Digital Creations and
! # many individuals on behalf of Digital Creations. Specific
! # attributions are listed in the accompanying credits file.
! #
##############################################################################
"""Provide a thread-safe interface to regex
--- 1,13 ----
##############################################################################
! #
! # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
! #
! # This software is subject to the provisions of the Zope Public License,
! # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
! # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
! # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
! # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
! # FOR A PARTICULAR PURPOSE
! #
##############################################################################
"""Provide a thread-safe interface to regex
***************
*** 89,93 ****
from regsub import split, sub, gsub, splitx, capwords
! try:
import thread
except:
--- 17,21 ----
from regsub import split, sub, gsub, splitx, capwords
! try:
import thread
except:
***************
*** 107,111 ****
def __call__(self, *args, **kw):
self._a()
! try: return apply(self._f, args, kw)
finally: self._r()
--- 35,39 ----
def __call__(self, *args, **kw):
self._a()
! try: return self._f(*args, **kw)
finally: self._r()
***************
*** 124,128 ****
def __init__(self, *args):
! self._r=r=apply(regex.compile,args)
self._init(r)
--- 52,56 ----
def __init__(self, *args):
! self._r=r=regex(*compile, **args)
self._init(r)
***************
*** 144,148 ****
try: return self._r.search(string, pos)
finally: self.__r()
!
def search_group(self, str, group, pos=0):
"""Search a string for a pattern.
--- 72,76 ----
try: return self._r.search(string, pos)
finally: self.__r()
!
def search_group(self, str, group, pos=0):
"""Search a string for a pattern.
***************
*** 157,161 ****
l=r.search(str, pos)
if l < 0: return None
! return l, apply(r.group, group)
finally: self.__r()
--- 85,89 ----
l=r.search(str, pos)
if l < 0: return None
! return l, r.group(*group)
finally: self.__r()
***************
*** 172,176 ****
l=r.match(str, pos)
if l < 0: return None
! return l, apply(r.group, group)
finally: self.__r()
--- 100,104 ----
l=r.match(str, pos)
if l < 0: return None
! return l, r.group(*group)
finally: self.__r()
***************
*** 206,215 ****
def __init__(self, *args):
! self._r=r=apply(regex.symcomp,args)
self._init(r)
self.groupindex=r.groupindex
-
-
-
-
-
--- 134,138 ----
def __init__(self, *args):
! self._r=r=regex.symcomp(*args)
self._init(r)
self.groupindex=r.groupindex
|