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
25ab7e2a
Commit
25ab7e2a
authored
Oct 19, 2002
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed several problems identified by pychecker
parent
41ec2d75
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
37 deletions
+30
-37
lib/python/StructuredText/DocumentClass.py
lib/python/StructuredText/DocumentClass.py
+6
-4
lib/python/StructuredText/ST.py
lib/python/StructuredText/ST.py
+7
-4
lib/python/StructuredText/STDOM.py
lib/python/StructuredText/STDOM.py
+16
-28
lib/python/StructuredText/StructuredText.py
lib/python/StructuredText/StructuredText.py
+1
-1
No files found.
lib/python/StructuredText/DocumentClass.py
View file @
25ab7e2a
...
@@ -149,8 +149,8 @@ class StructuredTextTable(ST.StructuredTextParagraph):
...
@@ -149,8 +149,8 @@ class StructuredTextTable(ST.StructuredTextParagraph):
def
_getColorizableTexts
(
self
):
def
_getColorizableTexts
(
self
):
return
self
.
getColorizableTexts
()
return
self
.
getColorizableTexts
()
def
_setColorizableTexts
(
self
):
def
_setColorizableTexts
(
self
,
texts
):
return
self
.
setColorizableTexts
()
return
self
.
setColorizableTexts
(
texts
)
# StructuredTextRow holds StructuredTextColumns
# StructuredTextRow holds StructuredTextColumns
class
StructuredTextRow
(
ST
.
StructuredTextParagraph
):
class
StructuredTextRow
(
ST
.
StructuredTextParagraph
):
...
@@ -238,9 +238,9 @@ class StructuredTextMarkup(STDOM.Element):
...
@@ -238,9 +238,9 @@ class StructuredTextMarkup(STDOM.Element):
self
.
_attributes
=
kw
.
keys
()
self
.
_attributes
=
kw
.
keys
()
for
k
,
v
in
kw
.
items
():
setattr
(
self
,
k
,
v
)
for
k
,
v
in
kw
.
items
():
setattr
(
self
,
k
,
v
)
def
getChildren
(
self
,
type
=
type
,
lt
=
type
([])
):
def
getChildren
(
self
):
v
=
self
.
_value
v
=
self
.
_value
if
type
(
v
)
is
not
lt
:
v
=
[
v
]
if
not
isinstance
(
v
,
ListType
)
:
v
=
[
v
]
return
v
return
v
def
getColorizableTexts
(
self
):
return
self
.
_value
,
def
getColorizableTexts
(
self
):
return
self
.
_value
,
...
@@ -934,6 +934,8 @@ class DocumentClass:
...
@@ -934,6 +934,8 @@ class DocumentClass:
start,end = r.span()
start,end = r.span()
text = s[start:end]
text = s[start:end]
return (StructuredTextSGML(text),start,end)
return (StructuredTextSGML(text),start,end)
else:
return None
def doc_xref(self, s,
def doc_xref(self, s,
...
...
lib/python/StructuredText/ST.py
View file @
25ab7e2a
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
##############################################################################
##############################################################################
import
re
,
STDOM
import
re
,
STDOM
from
types
import
ListType
#####################################################################
#####################################################################
# Updated functions #
# Updated functions #
...
@@ -187,9 +188,9 @@ class StructuredTextParagraph(STDOM.Element):
...
@@ -187,9 +188,9 @@ class StructuredTextParagraph(STDOM.Element):
self._attributes=kw.keys()
self._attributes=kw.keys()
for k, v in kw.items(): setattr(self, k, v)
for k, v in kw.items(): setattr(self, k, v)
def getChildren(self
, type=type, lt=type([])
):
def getChildren(self):
src=self._src
src=self._src
if
type(src) is not lt
: src=[src]
if
not isinstance(src, ListType)
: src=[src]
return src+self._subs
return src+self._subs
def getAttribute(self, name):
def getAttribute(self, name):
...
@@ -198,6 +199,8 @@ class StructuredTextParagraph(STDOM.Element):
...
@@ -198,6 +199,8 @@ class StructuredTextParagraph(STDOM.Element):
def getAttributeNode(self, name):
def getAttributeNode(self, name):
if hasattr(self, name):
if hasattr(self, name):
return STDOM.Attr(name, getattr(self, name))
return STDOM.Attr(name, getattr(self, name))
else:
return None
def getAttributes(self):
def getAttributes(self):
d={}
d={}
...
@@ -231,8 +234,8 @@ class StructuredTextParagraph(STDOM.Element):
...
@@ -231,8 +234,8 @@ class StructuredTextParagraph(STDOM.Element):
create aliases for all above functions in the pythony way.
create aliases for all above functions in the pythony way.
"""
"""
def _get_Children(self
, type=type, lt=type([])
):
def _get_Children(self):
return self.getChildren(
type,lt
)
return self.getChildren()
def _get_Attribute(self, name):
def _get_Attribute(self, name):
return self.getAttribute(name)
return self.getAttribute(name)
...
...
lib/python/StructuredText/STDOM.py
View file @
25ab7e2a
...
@@ -121,7 +121,7 @@ class ParentNode:
...
@@ -121,7 +121,7 @@ class ParentNode:
"""
"""
children
=
self
.
getChildren
()
children
=
self
.
getChildren
()
if
not
children
:
return
None
if
not
children
:
return
None
n
=
chidren
[
-
1
]
n
=
chi
l
dren
[
-
1
]
if
type
(
n
)
in
sts
:
n
=
TextNode
(
n
)
if
type
(
n
)
in
sts
:
n
=
TextNode
(
n
)
return
n
.
__of__
(
self
)
return
n
.
__of__
(
self
)
...
@@ -168,11 +168,7 @@ class NodeWrapper(ParentNode):
...
@@ -168,11 +168,7 @@ class NodeWrapper(ParentNode):
i
=
i
+
1
i
=
i
+
1
return
None
return
None
def
getPreviousSibling
(
self
,
def
getPreviousSibling
(
self
):
type
=
type
,
sts
=
StringTypes
,
getattr
=
getattr
):
"""
"""
The node immediately preceding this node. If
The node immediately preceding this node. If
there is no such node, this returns None.
there is no such node, this returns None.
...
@@ -192,13 +188,13 @@ class NodeWrapper(ParentNode):
...
@@ -192,13 +188,13 @@ class NodeWrapper(ParentNode):
try
:
n
=
children
[
index
]
try
:
n
=
children
[
index
]
except
IndexError
:
return
None
except
IndexError
:
return
None
else
:
else
:
if
type
(
n
)
in
st
s
:
if
type
(
n
)
in
StringType
s
:
n
=
TextNode
(
n
)
n
=
TextNode
(
n
)
n
.
_DOMIndex
=
index
n
.
_DOMIndex
=
index
return
n
.
__of__
(
self
)
return
n
.
__of__
(
self
)
def
getNextSibling
(
self
,
type
=
type
,
sts
=
StringTypes
):
def
getNextSibling
(
self
):
"""
"""
The node immediately preceding this node. If
The node immediately preceding this node. If
there is no such node, this returns None.
there is no such node, this returns None.
...
@@ -218,7 +214,7 @@ class NodeWrapper(ParentNode):
...
@@ -218,7 +214,7 @@ class NodeWrapper(ParentNode):
except
IndexError
:
except
IndexError
:
return
None
return
None
else
:
else
:
if
type
(
n
)
in
st
s
:
if
type
(
n
)
in
StringType
s
:
n
=
TextNode
(
n
)
n
=
TextNode
(
n
)
n
.
_DOMIndex
=
index
n
.
_DOMIndex
=
index
return
n
.
__of__
(
self
)
return
n
.
__of__
(
self
)
...
@@ -239,15 +235,11 @@ class NodeWrapper(ParentNode):
...
@@ -239,15 +235,11 @@ class NodeWrapper(ParentNode):
def
_get_DOMIndex
(
self
,
children
,
getattr
=
getattr
):
def
_get_DOMIndex
(
self
,
children
,
getattr
=
getattr
):
return
self
.
_getDOMIndex
(
children
,
getattr
)
return
self
.
_getDOMIndex
(
children
,
getattr
)
def
_get_PreviousSibling
(
self
,
def
_get_PreviousSibling
(
self
):
type
=
type
,
return
self
.
getPreviousSibling
()
sts
=
StringTypes
,
getattr
=
getattr
):
return
self
.
getPreviousSibling
(
type
,
sts
,
getattr
,
None
)
def
_get_NextSibling
(
self
,
type
=
type
,
sts
=
StringTypes
):
def
_get_NextSibling
(
self
):
return
self
.
getNextSibling
(
type
,
sts
)
return
self
.
getNextSibling
()
def
_get_OwnerDocument
(
self
):
def
_get_OwnerDocument
(
self
):
return
self
.
getOwnerDocument
()
return
self
.
getOwnerDocument
()
...
@@ -340,14 +332,10 @@ class Node(ParentNode):
...
@@ -340,14 +332,10 @@ class Node(ParentNode):
def
_get_Children
(
self
):
def
_get_Children
(
self
):
return
self
.
getChildren
()
return
self
.
getChildren
()
def
_get_PreviousSibling
(
self
,
def
_get_PreviousSibling
(
self
):
type
=
type
,
return
self
.
getPreviousSibling
()
sts
=
StringTypes
,
getattr
=
getattr
):
return
self
.
getPreviousSibling
(
type
,
sts
,
getattr
,
None
)
def
_get_NextSibling
(
self
,
type
=
type
,
sts
=
StringTypes
):
def
_get_NextSibling
(
self
):
return
self
.
getNextSibling
()
return
self
.
getNextSibling
()
def
_get_Attributes
(
self
):
def
_get_Attributes
(
self
):
...
@@ -406,10 +394,10 @@ class Element(Node):
...
@@ -406,10 +394,10 @@ class Element(Node):
"""A code representing the type of the node."""
"""A code representing the type of the node."""
return
ELEMENT_NODE
return
ELEMENT_NODE
def
getNodeValue
(
self
,
type
=
type
,
sts
=
StringTypes
):
def
getNodeValue
(
self
):
r
=
[]
r
=
[]
for
c
in
self
.
getChildren
():
for
c
in
self
.
getChildren
():
if
type
(
c
)
not
in
st
s
:
if
type
(
c
)
not
in
StringType
s
:
c
=
c
.
getNodeValue
()
c
=
c
.
getNodeValue
()
r
.
append
(
c
)
r
.
append
(
c
)
return
''
.
join
(
r
)
return
''
.
join
(
r
)
...
@@ -479,8 +467,8 @@ class Element(Node):
...
@@ -479,8 +467,8 @@ class Element(Node):
def
_get_NodeType
(
self
):
def
_get_NodeType
(
self
):
return
self
.
getNodeType
()
return
self
.
getNodeType
()
def
_get_NodeValue
(
self
,
type
=
type
,
sts
=
StringTypes
):
def
_get_NodeValue
(
self
):
return
self
.
getNodeValue
(
type
,
sts
)
return
self
.
getNodeValue
()
def
_get_ParentNode
(
self
):
def
_get_ParentNode
(
self
):
return
self
.
getParentNode
()
return
self
.
getParentNode
()
...
...
lib/python/StructuredText/StructuredText.py
View file @
25ab7e2a
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
use of StructuredTextNG """
use of StructuredTextNG """
import
HTMLClass
,
DocumentClass
,
ClassicDocumentClass
import
HTMLClass
,
DocumentClass
import
DocumentWithImages
,
HTMLWithImages
import
DocumentWithImages
,
HTMLWithImages
from
ST
import
Basic
from
ST
import
Basic
...
...
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