* fix: make some get and add functions work, passes testAdd in xmlext tests

* bear with the fluctuation :)
This commit is contained in:
Eray Özkural
2005-11-09 21:41:34 +00:00
parent ba71e8f791
commit a810f98d01
6 changed files with 16 additions and 15 deletions
+2 -2
View File
@@ -25,14 +25,14 @@
""" """
# System # System
import xml.dom.minidom as mdom
from xml.parsers.expat import ExpatError
import locale import locale
import codecs import codecs
import types import types
import formatter import formatter
import sys import sys
from StringIO import StringIO from StringIO import StringIO
#import xml.dom.minidom as mdom
#from xml.parsers.expat import ExpatError
import gettext import gettext
__trans = gettext.translation('pisi', fallback=True) __trans = gettext.translation('pisi', fallback=True)
+2 -2
View File
@@ -12,8 +12,8 @@
# Authors: Eray Ozkural <eray@uludag.org.tr> # Authors: Eray Ozkural <eray@uludag.org.tr>
try: try:
#from xmlextpiks import * #zimbabwe # comment out to disable piks
zimbabwe from xmlextpiks import *
except: except:
print 'xmlext: piksemel implementation cannot be loaded, falling back to minidom' print 'xmlext: piksemel implementation cannot be loaded, falling back to minidom'
from xmlextmdom import * from xmlextmdom import *
+1 -1
View File
@@ -195,4 +195,4 @@ def addNode(node, tagpath, newnode = None, branch=True):
def addText(node, tagPath, text, branch = True): def addText(node, tagPath, text, branch = True):
newnode = newTextNode(node, text) newnode = newTextNode(node, text)
addNode(node, tagPath, newnode, branch) return addNode(node, tagPath, newnode, branch = branch)
+6 -5
View File
@@ -39,10 +39,10 @@ def getNodeAttribute(node, attrname):
def getChildElts(node): def getChildElts(node):
"""get only child elements""" """get only child elements"""
return [x for x in parent.childNodes if x.type == TAG ] return [x for x in parent.childNodes if x.type() == TAG ]
def getTagByName(parent, childName): def getTagByName(parent, childName):
return [x for x in parent if x.type == TAG and x.name == childName] return [x for x in parent if x.type() == TAG and x.name() == childName]
def getNodeText(node, tagpath = ""): def getNodeText(node, tagpath = ""):
"""get the first child and expect it to be text!""" """get the first child and expect it to be text!"""
@@ -110,7 +110,7 @@ def createTagPath(node, tags):
if len(tags)==0: if len(tags)==0:
return node return node
for tag in tags: for tag in tags:
node = node.appendTag(Node(tag)) node = node.appendTag(tag)
return node return node
def addTagPath(node, tags, newnode=None): def addTagPath(node, tags, newnode=None):
@@ -163,6 +163,7 @@ def addNode(node, tagpath, newnode = None, branch=True):
#def newTextNode(node, text): #def newTextNode(node, text):
# return Node(text) # return Node(text)
def addText(node, tagPath, text, branch = True): def addText(node, tagPath, text, branch = True):
newnode = newTextNode(node, text) node = addNode(node, tagPath, branch = branch)
addNode(node, tagPath, newnode, branch) return node.appendData(text)
+3 -3
View File
@@ -12,9 +12,9 @@
# Authors: Eray Ozkural <eray@uludag.org.tr> # Authors: Eray Ozkural <eray@uludag.org.tr>
try: try:
#from xmlextpiks import * #horagata # comment out to disable piks
#from xmlfilepiks import * from xmlextpiks import *
horagata from xmlfilepiks import *
except: except:
print 'xmlfile: piksemel implementation cannot be loaded, falling back to minidom' print 'xmlfile: piksemel implementation cannot be loaded, falling back to minidom'
from xmlfilemdom import * from xmlfilemdom import *
+1 -1
View File
@@ -34,7 +34,7 @@ class XmlExtTestCase(testcase.TestCase):
self.assertEqual(xmlext.getNodeText(codeswith[2]), 'Caglar') self.assertEqual(xmlext.getNodeText(codeswith[2]), 'Caglar')
def testAdd(self): def testAdd(self):
node = xmlext.newDocument('team') node = xmlext.newDocument('pardus')
#node = a.documentElement #node = a.documentElement
xmlext.addText(node, 'team/coder', 'zibidi1') xmlext.addText(node, 'team/coder', 'zibidi1')
xmlext.addText(node, 'team/coder', 'zibidi2') xmlext.addText(node, 'team/coder', 'zibidi2')