Commit 25ab7e2a authored by Andreas Jung's avatar Andreas Jung

fixed several problems identified by pychecker

parent 41ec2d75
......@@ -149,8 +149,8 @@ class StructuredTextTable(ST.StructuredTextParagraph):
def _getColorizableTexts(self):
return self.getColorizableTexts()
def _setColorizableTexts(self):
return self.setColorizableTexts()
def _setColorizableTexts(self, texts):
return self.setColorizableTexts(texts)
# StructuredTextRow holds StructuredTextColumns
class StructuredTextRow(ST.StructuredTextParagraph):
......@@ -238,9 +238,9 @@ class StructuredTextMarkup(STDOM.Element):
self._attributes=kw.keys()
for k, v in kw.items(): setattr(self, k, v)
def getChildren(self, type=type, lt=type([])):
def getChildren(self):
v=self._value
if type(v) is not lt: v=[v]
if not isinstance(v, ListType): v=[v]
return v
def getColorizableTexts(self): return self._value,
......@@ -934,6 +934,8 @@ class DocumentClass:
start,end = r.span()
text = s[start:end]
return (StructuredTextSGML(text),start,end)
else:
return None
def doc_xref(self, s,
......
......@@ -12,6 +12,7 @@
##############################################################################
import re, STDOM
from types import ListType
#####################################################################
# Updated functions #
......@@ -187,9 +188,9 @@ class StructuredTextParagraph(STDOM.Element):
self._attributes=kw.keys()
for k, v in kw.items(): setattr(self, k, v)
def getChildren(self, type=type, lt=type([])):
def getChildren(self):
src=self._src
if type(src) is not lt: src=[src]
if not isinstance(src, ListType): src=[src]
return src+self._subs
def getAttribute(self, name):
......@@ -198,6 +199,8 @@ class StructuredTextParagraph(STDOM.Element):
def getAttributeNode(self, name):
if hasattr(self, name):
return STDOM.Attr(name, getattr(self, name))
else:
return None
def getAttributes(self):
d={}
......@@ -231,8 +234,8 @@ class StructuredTextParagraph(STDOM.Element):
create aliases for all above functions in the pythony way.
"""
def _get_Children(self, type=type, lt=type([])):
return self.getChildren(type,lt)
def _get_Children(self):
return self.getChildren()
def _get_Attribute(self, name):
return self.getAttribute(name)
......
......@@ -121,7 +121,7 @@ class ParentNode:
"""
children = self.getChildren()
if not children: return None
n=chidren[-1]
n=children[-1]
if type(n) in sts: n=TextNode(n)
return n.__of__(self)
......@@ -168,11 +168,7 @@ class NodeWrapper(ParentNode):
i=i+1
return None
def getPreviousSibling(self,
type=type,
sts=StringTypes,
getattr=getattr):
def getPreviousSibling(self):
"""
The node immediately preceding this node. If
there is no such node, this returns None.
......@@ -192,13 +188,13 @@ class NodeWrapper(ParentNode):
try: n=children[index]
except IndexError: return None
else:
if type(n) in sts:
if type(n) in StringTypes:
n=TextNode(n)
n._DOMIndex=index
return n.__of__(self)
def getNextSibling(self, type=type, sts=StringTypes):
def getNextSibling(self):
"""
The node immediately preceding this node. If
there is no such node, this returns None.
......@@ -218,7 +214,7 @@ class NodeWrapper(ParentNode):
except IndexError:
return None
else:
if type(n) in sts:
if type(n) in StringTypes:
n=TextNode(n)
n._DOMIndex=index
return n.__of__(self)
......@@ -239,15 +235,11 @@ class NodeWrapper(ParentNode):
def _get_DOMIndex(self, children, getattr=getattr):
return self._getDOMIndex(children,getattr)
def _get_PreviousSibling(self,
type=type,
sts=StringTypes,
getattr=getattr):
return self.getPreviousSibling(type,sts,getattr,None)
def _get_PreviousSibling(self):
return self.getPreviousSibling()
def _get_NextSibling(self, type=type, sts=StringTypes):
return self.getNextSibling(type,sts)
def _get_NextSibling(self):
return self.getNextSibling()
def _get_OwnerDocument(self):
return self.getOwnerDocument()
......@@ -340,14 +332,10 @@ class Node(ParentNode):
def _get_Children(self):
return self.getChildren()
def _get_PreviousSibling(self,
type=type,
sts=StringTypes,
getattr=getattr):
return self.getPreviousSibling(type,sts,getattr,None)
def _get_PreviousSibling(self):
return self.getPreviousSibling()
def _get_NextSibling(self, type=type, sts=StringTypes):
def _get_NextSibling(self):
return self.getNextSibling()
def _get_Attributes(self):
......@@ -406,10 +394,10 @@ class Element(Node):
"""A code representing the type of the node."""
return ELEMENT_NODE
def getNodeValue(self, type=type, sts=StringTypes):
def getNodeValue(self):
r=[]
for c in self.getChildren():
if type(c) not in sts:
if type(c) not in StringTypes:
c=c.getNodeValue()
r.append(c)
return ''.join(r)
......@@ -479,8 +467,8 @@ class Element(Node):
def _get_NodeType(self):
return self.getNodeType()
def _get_NodeValue(self, type=type, sts=StringTypes):
return self.getNodeValue(type,sts)
def _get_NodeValue(self):
return self.getNodeValue()
def _get_ParentNode(self):
return self.getParentNode()
......
......@@ -15,7 +15,7 @@
use of StructuredTextNG """
import HTMLClass, DocumentClass, ClassicDocumentClass
import HTMLClass, DocumentClass
import DocumentWithImages, HTMLWithImages
from ST import Basic
......
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