def dump_number(self, value, write): # PHP can't handle values over 1073741824 if int(value) > 1073741824: write("<value><string>") write(xmlrpclib.escape(str(value))) write("</string></value>\n") else: if type(value) is float: write('<value><double>%s</dobule></value>' % str(value)) else: write('<value><int>%s</int></value>' % str(value))
def test_escape(self): self.assertEqual(xmlrpclib.escape("a&b"), "a&b") self.assertEqual(xmlrpclib.escape("a<b"), "a<b") self.assertEqual(xmlrpclib.escape("a>b"), "a>b")
_dtypes[3]: 2, #TODO: should be enum (1) _dtypes[4]: 2, _dtypes[5]: 2, _dtypes[6]: 3, _dtypes[7]: 0, _dtypes[8]: 2, _dtypes[9]: 3, _dtypes[10]: 2, #TODO: should be enum (1) _dtypes[11]: 2, _dtypes[12]: 2, _dtypes[13]: 3, _dtypes[14]: 2, } _encoder = { 0: lambda v: "<value><string>%s</string></value>" % escape(v), 2: lambda v: "<value><int>%s</int></value>" % str(int(v)), 3: lambda v: "<value><double>%s</double></value>" % repr(v), } # Some default meta-data _static_meta = "<struct>\n"+\ "<member>\n<name>units</name>\n<value><string></string></value>\n</member>\n"+\ "<member>\n<name>warn_high</name>\n<value><double>0.0</double></value>\n</member>\n"+\ "<member>\n<name>alarm_high</name>\n<value><double>0.0</double></value>\n</member>\n"+\ "<member>\n<name>disp_high</name>\n<value><double>0.0</double></value>\n</member>\n"+\ "<member>\n<name>warn_low</name>\n<value><double>0.0</double></value>\n</member>\n"+\ "<member>\n<name>type</name>\n<value><int>1</int></value>\n</member>\n"+\ "<member>\n<name>alarm_low</name>\n<value><double>0.0</double></value>\n</member>\n"+\ "<member>\n<name>prec</name>\n<value><int>0</int></value>\n</member>\n"+\ "<member>\n<name>disp_low</name>\n<value><double>0.0</double></value>\n</member>\n"+\
def dump_datetime(self, value, write): write("<value><string>") write(xmlrpclib.escape(str(value))) write("</string></value>\n")
def dump_none(self, value, write): write("<value><string>") write(xmlrpclib.escape('')) write("</string></value>\n")
_dtypes[3]:2, #TODO: should be enum (1) _dtypes[4]:2, _dtypes[5]:2, _dtypes[6]:3, _dtypes[7]:0, _dtypes[8]:2, _dtypes[9]:3, _dtypes[10]:2, #TODO: should be enum (1) _dtypes[11]:2, _dtypes[12]:2, _dtypes[13]:3, _dtypes[14]:2, } _encoder = { 0:lambda v:"<value><string>%s</string></value>"%escape(v), 2:lambda v:"<value><int>%s</int></value>"%str(int(v)), 3:lambda v:"<value><double>%s</double></value>"%repr(v), } # Some default meta-data _static_meta = "<struct>\n"+\ "<member>\n<name>units</name>\n<value><string></string></value>\n</member>\n"+\ "<member>\n<name>warn_high</name>\n<value><double>0.0</double></value>\n</member>\n"+\ "<member>\n<name>alarm_high</name>\n<value><double>0.0</double></value>\n</member>\n"+\ "<member>\n<name>disp_high</name>\n<value><double>0.0</double></value>\n</member>\n"+\ "<member>\n<name>warn_low</name>\n<value><double>0.0</double></value>\n</member>\n"+\ "<member>\n<name>type</name>\n<value><int>1</int></value>\n</member>\n"+\ "<member>\n<name>alarm_low</name>\n<value><double>0.0</double></value>\n</member>\n"+\ "<member>\n<name>prec</name>\n<value><int>0</int></value>\n</member>\n"+\ "<member>\n<name>disp_low</name>\n<value><double>0.0</double></value>\n</member>\n"+\