Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
d4dee996
Commit
d4dee996
authored
Feb 27, 2003
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove uses of apply(). These will generate PendingDeprecationWarnings in
Python 2.3.
parent
5ac86b5e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
31 deletions
+23
-31
lib/python/StructuredText/ClassicDocumentClass.py
lib/python/StructuredText/ClassicDocumentClass.py
+7
-10
lib/python/StructuredText/DocumentClass.py
lib/python/StructuredText/DocumentClass.py
+10
-13
lib/python/StructuredText/ST.py
lib/python/StructuredText/ST.py
+1
-3
lib/python/StructuredText/ts_regex.py
lib/python/StructuredText/ts_regex.py
+5
-5
No files found.
lib/python/StructuredText/ClassicDocumentClass.py
View file @
d4dee996
...
@@ -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
):
...
...
lib/python/StructuredText/DocumentClass.py
View file @
d4dee996
...
@@ -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)
...
...
lib/python/StructuredText/ST.py
View file @
d4dee996
...
@@ -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
...
...
lib/python/StructuredText/ts_regex.py
View file @
d4dee996
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment