* 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
+3 -3
View File
@@ -25,14 +25,14 @@
"""
# System
import xml.dom.minidom as mdom
from xml.parsers.expat import ExpatError
import locale
import codecs
import types
import formatter
import sys
from StringIO import StringIO
#import xml.dom.minidom as mdom
#from xml.parsers.expat import ExpatError
import gettext
__trans = gettext.translation('pisi', fallback=True)
@@ -105,7 +105,7 @@ class LocalText(dict):
newtext = newTextNode(node, self[key])
newnode.appendChild(newtext)
node.appendChild(newnode)
def errors(self, where = unicode()):
errs = []
langs = [ locale.getlocale()[0][0:2], 'tr', 'en' ]
+2 -2
View File
@@ -12,8 +12,8 @@
# Authors: Eray Ozkural <eray@uludag.org.tr>
try:
#from xmlextpiks import *
zimbabwe
#zimbabwe # comment out to disable piks
from xmlextpiks import *
except:
print 'xmlext: piksemel implementation cannot be loaded, falling back to minidom'
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):
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):
"""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):
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 = ""):
"""get the first child and expect it to be text!"""
@@ -110,7 +110,7 @@ def createTagPath(node, tags):
if len(tags)==0:
return node
for tag in tags:
node = node.appendTag(Node(tag))
node = node.appendTag(tag)
return node
def addTagPath(node, tags, newnode=None):
@@ -163,6 +163,7 @@ def addNode(node, tagpath, newnode = None, branch=True):
#def newTextNode(node, text):
# return Node(text)
def addText(node, tagPath, text, branch = True):
newnode = newTextNode(node, text)
addNode(node, tagPath, newnode, branch)
node = addNode(node, tagPath, branch = branch)
return node.appendData(text)
+3 -3
View File
@@ -12,9 +12,9 @@
# Authors: Eray Ozkural <eray@uludag.org.tr>
try:
#from xmlextpiks import *
#from xmlfilepiks import *
horagata
#horagata # comment out to disable piks
from xmlextpiks import *
from xmlfilepiks import *
except:
print 'xmlfile: piksemel implementation cannot be loaded, falling back to minidom'
from xmlfilemdom import *
+1 -1
View File
@@ -34,7 +34,7 @@ class XmlExtTestCase(testcase.TestCase):
self.assertEqual(xmlext.getNodeText(codeswith[2]), 'Caglar')
def testAdd(self):
node = xmlext.newDocument('team')
node = xmlext.newDocument('pardus')
#node = a.documentElement
xmlext.addText(node, 'team/coder', 'zibidi1')
xmlext.addText(node, 'team/coder', 'zibidi2')