Commit d4dee996 authored by Fred Drake's avatar Fred Drake

Remove uses of apply(). These will generate PendingDeprecationWarnings in

Python 2.3.
parent 5ac86b5e
...@@ -23,9 +23,7 @@ class StructuredTextExample(ST.StructuredTextParagraph): ...@@ -23,9 +23,7 @@ class StructuredTextExample(ST.StructuredTextParagraph):
def __init__(self, subs, **kw): def __init__(self, subs, **kw):
t=[]; a=t.append t=[]; a=t.append
for s in subs: a(s.getNodeValue()) for s in subs: a(s.getNodeValue())
apply(ST.StructuredTextParagraph.__init__, ST.StructuredTextParagraph.__init__(self, '\n\n'.join(t), (), **kw)
(self, '\n\n'.join(t), ()),
kw)
def getColorizableTexts(self): return () def getColorizableTexts(self): return ()
def setColorizableTexts(self, src): pass # never color examples def setColorizableTexts(self, src): pass # never color examples
...@@ -46,7 +44,7 @@ class StructuredTextDescription(ST.StructuredTextParagraph): ...@@ -46,7 +44,7 @@ class StructuredTextDescription(ST.StructuredTextParagraph):
"""Represents a section of a document with a title and a body""" """Represents a section of a document with a title and a body"""
def __init__(self, title, src, subs, **kw): def __init__(self, title, src, subs, **kw):
apply(ST.StructuredTextParagraph.__init__, (self, src, subs), kw) ST.StructuredTextParagraph.__init__(self, src, subs, **kw)
self._title=title self._title=title
def getColorizableTexts(self): return self._title, self._src def getColorizableTexts(self): return self._title, self._src
...@@ -62,9 +60,8 @@ class StructuredTextSectionTitle(ST.StructuredTextParagraph): ...@@ -62,9 +60,8 @@ class StructuredTextSectionTitle(ST.StructuredTextParagraph):
class StructuredTextSection(ST.StructuredTextParagraph): class StructuredTextSection(ST.StructuredTextParagraph):
"""Represents a section of a document with a title and a body""" """Represents a section of a document with a title and a body"""
def __init__(self, src, subs=None, **kw): def __init__(self, src, subs=None, **kw):
apply(ST.StructuredTextParagraph.__init__, ST.StructuredTextParagraph.__init__(
(self, StructuredTextSectionTitle(src), subs), self, StructuredTextSectionTitle(src), subs, **kw)
kw)
def getColorizableTexts(self): def getColorizableTexts(self):
return self._src.getColorizableTexts() return self._src.getColorizableTexts()
...@@ -82,7 +79,7 @@ class StructuredTextTable(ST.StructuredTextDocument): ...@@ -82,7 +79,7 @@ class StructuredTextTable(ST.StructuredTextDocument):
""" """
def __init__(self, rows, src, subs, **kw): def __init__(self, rows, src, subs, **kw):
apply(ST.StructuredTextDocument.__init__,(self,subs),kw) ST.StructuredTextDocument.__init__(self, subs, **kw)
self._rows = [] self._rows = []
for row in rows: for row in rows:
if row: if row:
...@@ -138,7 +135,7 @@ class StructuredTextRow(ST.StructuredTextDocument): ...@@ -138,7 +135,7 @@ class StructuredTextRow(ST.StructuredTextDocument):
EX EX
[('this is column one',1), ('this is column two',1)] [('this is column one',1), ('this is column two',1)]
""" """
apply(ST.StructuredTextDocument.__init__,(self,[]),kw) ST.StructuredTextDocument.__init__(self, [], **kw)
self._columns = [] self._columns = []
for column in row: for column in row:
self._columns.append(StructuredTextColumn(column[0],column[1],kw)) self._columns.append(StructuredTextColumn(column[0],column[1],kw))
...@@ -158,7 +155,7 @@ class StructuredTextColumn(ST.StructuredTextParagraph): ...@@ -158,7 +155,7 @@ class StructuredTextColumn(ST.StructuredTextParagraph):
""" """
def __init__(self,text,span,kw): def __init__(self,text,span,kw):
apply(ST.StructuredTextParagraph.__init__,(self,text,[]),kw) ST.StructuredTextParagraph.__init__(self, text, [], **kw)
self._span = span self._span = span
def getSpan(self): def getSpan(self):
......
...@@ -34,9 +34,7 @@ class StructuredTextExample(ST.StructuredTextParagraph): ...@@ -34,9 +34,7 @@ class StructuredTextExample(ST.StructuredTextParagraph):
a=t.append a=t.append
for s in subs: for s in subs:
flatten(s, a) flatten(s, a)
apply(ST.StructuredTextParagraph.__init__, ST.StructuredTextParagraph.__init__(self, '\n\n'.join(t), (), **kw)
(self, '\n\n'.join(t), ()),
kw)
def getColorizableTexts(self): return () def getColorizableTexts(self): return ()
def setColorizableTexts(self, src): pass # never color examples def setColorizableTexts(self, src): pass # never color examples
...@@ -57,7 +55,7 @@ class StructuredTextDescription(ST.StructuredTextParagraph): ...@@ -57,7 +55,7 @@ class StructuredTextDescription(ST.StructuredTextParagraph):
"""Represents a section of a document with a title and a body""" """Represents a section of a document with a title and a body"""
def __init__(self, title, src, subs, **kw): def __init__(self, title, src, subs, **kw):
apply(ST.StructuredTextParagraph.__init__, (self, src, subs), kw) ST.StructuredTextParagraph.__init__(self, src, subs, **kw)
self._title=title self._title=title
def getColorizableTexts(self): return self._title, self._src def getColorizableTexts(self): return self._title, self._src
...@@ -73,9 +71,8 @@ class StructuredTextSectionTitle(ST.StructuredTextParagraph): ...@@ -73,9 +71,8 @@ class StructuredTextSectionTitle(ST.StructuredTextParagraph):
class StructuredTextSection(ST.StructuredTextParagraph): class StructuredTextSection(ST.StructuredTextParagraph):
"""Represents a section of a document with a title and a body""" """Represents a section of a document with a title and a body"""
def __init__(self, src, subs=None, **kw): def __init__(self, src, subs=None, **kw):
apply(ST.StructuredTextParagraph.__init__, ST.StructuredTextParagraph.__init__(
(self, StructuredTextSectionTitle(src), subs), self, StructuredTextSectionTitle(src), subs, **kw)
kw)
def getColorizableTexts(self): def getColorizableTexts(self):
return self._src.getColorizableTexts() return self._src.getColorizableTexts()
...@@ -93,7 +90,7 @@ class StructuredTextTable(ST.StructuredTextParagraph): ...@@ -93,7 +90,7 @@ class StructuredTextTable(ST.StructuredTextParagraph):
""" """
def __init__(self, rows, src, subs, **kw): def __init__(self, rows, src, subs, **kw):
apply(ST.StructuredTextParagraph.__init__,(self,subs),kw) ST.StructuredTextParagraph.__init__(self, subs, **kw)
self._rows = [] self._rows = []
for row in rows: for row in rows:
if row: if row:
...@@ -164,7 +161,7 @@ class StructuredTextRow(ST.StructuredTextParagraph): ...@@ -164,7 +161,7 @@ class StructuredTextRow(ST.StructuredTextParagraph):
[('this is column one',1), ('this is column two',1)] [('this is column one',1), ('this is column two',1)]
""" """
apply(ST.StructuredTextParagraph.__init__,(self,[]),kw) ST.StructuredTextParagraph.__init__(self, [], **kw)
self._columns = [] self._columns = []
for column in row: for column in row:
...@@ -197,7 +194,7 @@ class StructuredTextColumn(ST.StructuredTextParagraph): ...@@ -197,7 +194,7 @@ class StructuredTextColumn(ST.StructuredTextParagraph):
""" """
def __init__(self,text,span,align,valign,typ,kw): def __init__(self,text,span,align,valign,typ,kw):
apply(ST.StructuredTextParagraph.__init__,(self,text,[]),kw) ST.StructuredTextParagraph.__init__(self, text, [], **kw)
self._span = span self._span = span
self._align = align self._align = align
self._valign = valign self._valign = valign
...@@ -427,8 +424,8 @@ class DocumentClass: ...@@ -427,8 +424,8 @@ class DocumentClass:
atts = getattr(paragraph, '_attributes', []) atts = getattr(paragraph, '_attributes', [])
for att in atts: kw[att] = getattr(paragraph, att) for att in atts: kw[att] = getattr(paragraph, att)
subs = self.color_paragraphs(paragraph.getSubparagraphs()) subs = self.color_paragraphs(paragraph.getSubparagraphs())
new_paragraphs=apply(ST.StructuredTextParagraph, new_paragraphs=ST.StructuredTextParagraph(
(paragraph.getColorizableTexts()[0], subs), kw), paragraph. getColorizableTexts()[0], subs, **kw),
# color the inline StructuredText types # color the inline StructuredText types
# for each StructuredTextParagraph # for each StructuredTextParagraph
...@@ -782,7 +779,7 @@ class DocumentClass: ...@@ -782,7 +779,7 @@ class DocumentClass:
kw = {} kw = {}
atts = getattr(paragraph, '_attributes', []) atts = getattr(paragraph, '_attributes', [])
for att in atts: kw[att] = getattr(paragraph, att) for att in atts: kw[att] = getattr(paragraph, att)
return apply(ST.StructuredTextParagraph, (top[:-1], [subs]), kw) return ST.StructuredTextParagraph(top[:-1], [subs], **kw)
if top.find('\n') >= 0: return None if top.find('\n') >= 0: return None
return StructuredTextSection(top, subs, indent=paragraph.indent) return StructuredTextSection(top, subs, indent=paragraph.indent)
......
...@@ -266,9 +266,7 @@ class StructuredTextDocument(StructuredTextParagraph): ...@@ -266,9 +266,7 @@ class StructuredTextDocument(StructuredTextParagraph):
_attributes=() _attributes=()
def __init__(self, subs=None, **kw): def __init__(self, subs=None, **kw):
apply(StructuredTextParagraph.__init__, StructuredTextParagraph.__init__(self, '', subs, **kw)
(self, '', subs),
kw)
def getChildren(self): def getChildren(self):
return self._subs return self._subs
......
...@@ -34,7 +34,7 @@ else: ...@@ -34,7 +34,7 @@ else:
def __call__(self, *args, **kw): def __call__(self, *args, **kw):
self._a() self._a()
try: return apply(self._f, args, kw) try: return self._f(*args, **kw)
finally: self._r() finally: self._r()
split=SafeFunction(split) split=SafeFunction(split)
...@@ -51,7 +51,7 @@ class compile: ...@@ -51,7 +51,7 @@ class compile:
groupindex=None groupindex=None
def __init__(self, *args): def __init__(self, *args):
self._r=r=apply(regex.compile,args) self._r=r=regex(*compile, **args)
self._init(r) self._init(r)
def _init(self, r): def _init(self, r):
...@@ -84,7 +84,7 @@ class compile: ...@@ -84,7 +84,7 @@ class compile:
r=self._r r=self._r
l=r.search(str, pos) l=r.search(str, pos)
if l < 0: return None if l < 0: return None
return l, apply(r.group, group) return l, r.group(*group)
finally: self.__r() finally: self.__r()
def match_group(self, str, group, pos=0): def match_group(self, str, group, pos=0):
...@@ -99,7 +99,7 @@ class compile: ...@@ -99,7 +99,7 @@ class compile:
r=self._r r=self._r
l=r.match(str, pos) l=r.match(str, pos)
if l < 0: return None if l < 0: return None
return l, apply(r.group, group) return l, r.group(*group)
finally: self.__r() finally: self.__r()
def search_regs(self, str, pos=0): def search_regs(self, str, pos=0):
...@@ -133,6 +133,6 @@ class compile: ...@@ -133,6 +133,6 @@ class compile:
class symcomp(compile): class symcomp(compile):
def __init__(self, *args): def __init__(self, *args):
self._r=r=apply(regex.symcomp,args) self._r=r=regex.symcomp(*args)
self._init(r) self._init(r)
self.groupindex=r.groupindex self.groupindex=r.groupindex
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