* fix: make some get and add functions work, passes testAdd in xmlext tests
* bear with the fluctuation :)
This commit is contained in:
+3
-3
@@ -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)
|
||||||
@@ -105,7 +105,7 @@ class LocalText(dict):
|
|||||||
newtext = newTextNode(node, self[key])
|
newtext = newTextNode(node, self[key])
|
||||||
newnode.appendChild(newtext)
|
newnode.appendChild(newtext)
|
||||||
node.appendChild(newnode)
|
node.appendChild(newnode)
|
||||||
|
|
||||||
def errors(self, where = unicode()):
|
def errors(self, where = unicode()):
|
||||||
errs = []
|
errs = []
|
||||||
langs = [ locale.getlocale()[0][0:2], 'tr', 'en' ]
|
langs = [ locale.getlocale()[0][0:2], 'tr', 'en' ]
|
||||||
|
|||||||
+2
-2
@@ -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 *
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
@@ -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 *
|
||||||
|
|||||||
@@ -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')
|
||||||
|
|||||||
Reference in New Issue
Block a user