[Dev OpenGP] [46] some test stuff

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


Revision: 46
Author:   nicolaf
Date:     2009-03-17 01:12:34 +0100 (Tue, 17 Mar 2009)

Log Message:
-----------
some test stuff

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

Added Paths:
-----------
    trunk/src/merge-test.py
    trunk/src/text.py


Modified: trunk/src/DomElementMethods/ElementMethods.py
===================================================================
--- trunk/src/DomElementMethods/ElementMethods.py	2009-03-16 19:00:54 UTC (rev 45)
+++ trunk/src/DomElementMethods/ElementMethods.py	2009-03-17 00:12:34 UTC (rev 46)
@@ -12,11 +12,12 @@
 		ElementBase.__init__(self, tag, attrib)
 	
 	def __setattr__(self, item, value):
-		if item == "text":
-			print "Deleting all subelements..."
+		if item == "text" and value is not None:
+			#print "Deleting all subelements..."
+			#print "self.tag: " + self.tag + " text: " + value
 			self.delElements()
 		if item == "tail":
-			print "Tail must be none"
+			#print "Tail must be none"
 			value = None
 		
 		ElementBase.__setattr__(self, item, value)
@@ -24,11 +25,8 @@
 	def __getAttributes(self):
 		res = dict()
 		for key in self.attrib:
-			res[key] = self.attrib[key]
-		try:
-			del res[ATTR_BLOCK]
-		except:
-			pass
+			if key != ATTR_BLOCK:
+				res[key] = self.attrib[key]
 		return res
 	attributes = property(__getAttributes)
 
@@ -171,7 +169,6 @@
 			for k, e in selfCommon.iteritems():
 				e.merge(deepcopy(peerCommon[k]))
 
-
 	def __reorder_ids(self, peer):
 		assert isinstance(peer, OgpElement)
 
@@ -185,7 +182,7 @@
 			for e in self:
 				id = e.get(ATTR_ID)
 				if id is not None:
-					e.set(ATTR_ID, str(int(id)) + peerMaxId + 1)
+					e.set(ATTR_ID, str(int(id) + peerMaxId + 1))
 
 	def toString(self):
 		return tostring(self)

Added: trunk/src/merge-test.py
===================================================================
--- trunk/src/merge-test.py	                        (rev 0)
+++ trunk/src/merge-test.py	2009-03-17 00:12:34 UTC (rev 46)
@@ -0,0 +1,13 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*
+from lxml.etree import *
+from DomElementMethods import *
+import StringIO
+
+parent=fromstring('<ogp><a>parent</a><b block="True">parent</b><c><parent/></c></ogp>', OGP_PARSER)
+child=fromstring('<ogp><a>child</a><b>child</b><c><child/></c></ogp>', OGP_PARSER)
+
+print "parent :\n" + parent.toString()
+print "child :\n" + child.toString()
+parent.merge(child)
+print "merge :\n" + parent.toString()


Property changes on: trunk/src/merge-test.py
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/src/text.py
===================================================================
--- trunk/src/text.py	                        (rev 0)
+++ trunk/src/text.py	2009-03-17 00:12:34 UTC (rev 46)
@@ -0,0 +1,9 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*
+from DomElementMethods import *
+
+obj = Element("AAA")
+obj.text = "pouet"
+print obj.text
+obj.tail = "test"
+print tostring(obj)


Property changes on: trunk/src/text.py
___________________________________________________________________
Name: svn:executable
   + *


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