[Dev OpenGP] [42] Little bugfix

[ Thread Index | Date Index | More opengp.tuxfamily.org/development Archives ]


Revision: 42
Author:   alband85
Date:     2009-03-16 10:35:37 +0100 (Mon, 16 Mar 2009)

Log Message:
-----------
Little bugfix

Modified Paths:
--------------
    trunk/src/DomElementMethods/ElementMethods.py
    trunk/src/DomElementMethods/__init__.py


Modified: trunk/src/DomElementMethods/ElementMethods.py
===================================================================
--- trunk/src/DomElementMethods/ElementMethods.py	2009-03-15 16:21:07 UTC (rev 41)
+++ trunk/src/DomElementMethods/ElementMethods.py	2009-03-16 09:35:37 UTC (rev 42)
@@ -63,7 +63,6 @@
 		Appends a new Text containing the text
 		Every Element child will be deleted by appendChild()
 	"""
-	self.delText()
 	textNode = Text()
 	textNode.data = text
 	self.appendChild(textNode)
@@ -175,40 +174,39 @@
 	if self.getText() is not None:
 		self.setText(peer.getText())
 		return
-	
-	#Second Case : nodes contains nodes
-	self.reorder_ids(peer)
-	
-	selfCommon=dict()
+	else: #Second Case : nodes contains nodes
+		self.reorder_ids(peer)
+		
+		selfCommon=dict()
 
-	peerNotCommon=[]
-	peerCommon=dict()
+		peerNotCommon=[]
+		peerCommon=dict()
 
-	for i in range(self.childNodes.length):
-		selfE = self.childNodes.item(i)
-		for j in range(peer.childNodes.length):
-			peerE = peer.childNodes.item(j)
-			if selfE.tagName == peerE.tagName and selfE.getAttributes() == peerE.getAttributes():
-				selfCommon[[selfE.tagName, selfE.getAttributes()]] = selfE
+		for i in range(self.childNodes.length):
+			selfE = self.childNodes.item(i)
+			for j in range(peer.childNodes.length):
+				peerE = peer.childNodes.item(j)
+				if selfE.tagName == peerE.tagName and selfE.getAttributes() == peerE.getAttributes():
+					selfCommon[[selfE.tagName, selfE.getAttributes()]] = selfE
 
-	for i in range(peer.childNodes.length):
-		peerE = peer.childNodes.item(i)
-		common = False
-		for j in range(self.childNodes.length):
-			selfE = self.childNodes.item(j)
-			if peerE.tagName == selfE.tagName and peerE.getAttributes() == selfE.getAttributes():
-				peerCommon[[peerE.tagName, peerE.getAttributes()]] = peerE
-				common = True
-		if not common:
-				peerNotCommon.append(peerE)
-	
-	#add peer children wich are not in common
-	for e in peerNotCommon:
-		self.appendChild(e.clone(deep))
+		for i in range(peer.childNodes.length):
+			peerE = peer.childNodes.item(i)
+			common = False
+			for j in range(self.childNodes.length):
+				selfE = self.childNodes.item(j)
+				if peerE.tagName == selfE.tagName and peerE.getAttributes() == selfE.getAttributes():
+					peerCommon[[peerE.tagName, peerE.getAttributes()]] = peerE
+					common = True
+			if not common:
+					peerNotCommon.append(peerE)
+		
+		#add peer children wich are not in common
+		for e in peerNotCommon:
+			self.appendChild(e.clone(deep))
 
-	#merge common children
-	for k, e in selfCommon.iteritems():
-		e.merge(peerCommon[k].clone(deep))
+		#merge common children
+		for k, e in selfCommon.iteritems():
+			e.merge(peerCommon[k].clone(deep))
 
 
 def reorder_ids(self, peer):
@@ -216,11 +214,11 @@
 	if peer.hasChildNodes() and self.hasChildNodes:
 		for i in range(peer.childNodes.length):
 			e=peer.childNodes.item(i)
-			if e.nodeType == Node.ELEMENT_NODE and e.hasAttribute(ATTR_ID) and int(e.getAttribute("ATTR_ID")) > peerMaxId:
-				peerMaxId = int(e.getAttribute("ATTR_ID"))
+			if e.nodeType == Node.ELEMENT_NODE and e.hasAttribute(ATTR_ID) and int(e.getAttribute(ATTR_ID)) > peerMaxId:
+				peerMaxId = int(e.getAttribute(ATTR_ID))
 
 		for i in range(self.childNodes.length):
 			e=self.childNodes.item(i)
 			if e.nodeType == Node.ELEMENT_NODE and e.hasAttribute(ATTR_ID):
-				e.setAttribute(ATTR_ID, str(int(e.getAttribute("ATTR_ID")) + peerMaxId + 1))
+				e.setAttribute(ATTR_ID, str(int(e.getAttribute(ATTR_ID)) + peerMaxId + 1))
 

Modified: trunk/src/DomElementMethods/__init__.py
===================================================================
--- trunk/src/DomElementMethods/__init__.py	2009-03-15 16:21:07 UTC (rev 41)
+++ trunk/src/DomElementMethods/__init__.py	2009-03-16 09:35:37 UTC (rev 42)
@@ -1,5 +1,6 @@
 #!/usr/bin/python
 # -*- coding: utf-8 -*
+
 from xml.dom.minidom import * 
 from ElementMethods import *
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/