/[escript]/trunk/esys2/escript/py_src/ESySParameters.py
ViewVC logotype

Diff of /trunk/esys2/escript/py_src/ESySParameters.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 104 by jgs, Tue Oct 26 06:53:54 2004 UTC revision 105 by jgs, Thu Dec 23 07:20:07 2004 UTC
# Line 198  class ESySParameters: Line 198  class ESySParameters:
198                 iostream.write("</%s>\n"%_PARAMETER)                 iostream.write("</%s>\n"%_PARAMETER)
199    
200    
201       def writeProperties(self, iostream, nameSpace = None):
202         """writes the object as a property list to an IO stream"""
203         if nameSpace != None and nameSpace != "":
204            nameSpace += ".";
205         for name,value in self.__dict__.iteritems():
206            if name[0]!="_":
207               if isinstance(value,ESySParameters):
208                  value.writeProperties(iostream, name)
209               else:
210                   if isinstance(value,types.ListType):
211                      sequence=_PARAMETER_SEQUENCE_LIST
212                      type=_getTypeNameOfList(value)
213                   elif isinstance(value,types.TupleType):
214                      sequence=_PARAMETER_SEQUENCE_TUPLE
215                      type=_getTypeNameOfList(value)
216                   else:
217                      sequence=_PARAMETER_SEQUENCE_SINGLE
218                      type=_getTypeName(value)
219                   iostream.write("%s = %s\n" % (nameSpace + name, value.__str__()))
220    
221     def writeESySXML(self,iostream):     def writeESySXML(self,iostream):
222          """writes an ESyS XML file"""          """writes an ESyS XML file"""
223          iostream.write("<?xml version=\"1.0\"?><ESyS>")          iostream.write("<?xml version=\"1.0\"?><ESyS>")
# Line 417  if  (__name__=="__main__"): Line 437  if  (__name__=="__main__"):
437      test(parm)      test(parm)
438      print "@@@ read and write:"      print "@@@ read and write:"
439      parm.writeESySXML(file("/tmp/test.xml",mode="w"))      parm.writeESySXML(file("/tmp/test.xml",mode="w"))
440        parm.writeProperties(file("/tmp/test.dat",mode="w"))
441      parm2=readESySXMLFile("/tmp/test.xml")      parm2=readESySXMLFile("/tmp/test.xml")
442      print parm2      print parm2
443      test(parm2)      test(parm2)

Legend:
Removed from v.104  
changed lines
  Added in v.105

  ViewVC Help
Powered by ViewVC 1.1.26