[MOBY-guts] biomoby commit
Yan Wong
yanwong at pub.open-bio.org
Mon May 16 12:42:01 UTC 2005
yanwong
Mon May 16 08:42:01 EDT 2005
Update of /home/repository/moby/moby-live/Python/bioMoby
In directory pub.open-bio.org:/tmp/cvs-serv22018
Modified Files:
mobyDataTypes.py
Log Message:
Modified the serialization/deserialization code:
from bioMoby import MobyMarshaller
m=MobyMarshaller()
m.dumps(0) should return <moby:Integer>0</moby:Integer> and not <moby:Integer/>
same for the float numbers ;)
this should fix problems of deserializing numbers.
moby-live/Python/bioMoby mobyDataTypes.py,1.20,1.21
===================================================================
RCS file: /home/repository/moby/moby-live/Python/bioMoby/mobyDataTypes.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- /home/repository/moby/moby-live/Python/bioMoby/mobyDataTypes.py 2005/04/26 15:09:59 1.20
+++ /home/repository/moby/moby-live/Python/bioMoby/mobyDataTypes.py 2005/05/16 12:42:01 1.21
@@ -107,7 +107,7 @@
mobyObjects=filter(filterFunc, dir(self))
#If none, return the tag closed
- if len(mobyObjects)==0 and (not hasattr(self, "__cross__") or len(self.__cross__)==0) and (not hasattr(self, "__PIB__") or len(self.__PIB__)==0) and (not hasattr(self, "content") or not self.content):
+ if len(mobyObjects)==0 and (not hasattr(self, "__cross__") or len(self.__cross__)==0) and (not hasattr(self, "__PIB__") or len(self.__PIB__)==0) and (not hasattr(self, "content") or (self.content==None or self.content=="")):
beginTag.append("/>")
return " ".join(beginTag)
@@ -149,8 +149,7 @@
#Put the raw content of the object
#If you want to put your special object, then then you should write
#a __str__ method
- if hasattr(self, "content") and self.content:
- result.append("%s"%(self.content))
+ result.append("%s"%(self.content))
result.append("</%s:%s>"%(self.__prefix__, self.__tag__))
@@ -269,7 +268,11 @@
def fromMoby(self, xml):
MobyObject.fromMoby(self, xml)
- self.content = int(self.content)
+
+ try:
+ self.content = int(self.content)
+ except:
+ self.content=0
class MobyFloat(MobyObject):
"""Serialize/deserialize floating point numbers
@@ -279,7 +282,11 @@
def fromMoby(self, xml):
MobyObject.fromMoby(self, xml)
- self.content=float(self.content)
+
+ try:
+ self.content=float(self.content)
+ except:
+ self.content=0.0
class MobyString(MobyObject):
More information about the MOBY-guts
mailing list