def __str__(self): answer = '[' + MagnitudeInterface.__str__(self) + ',' if self.units is None: answer += 'None]' else: answer += "'" + str(int(self.units)) + "']" return answer
def __init__(self, value=None, units=None): self.units = units #if units: #self.units = units_text[units] MagnitudeInterface.__init__(self, value)
print dumps((StringClass("Text with ]]>"), )) print """ # # The StringMarshaller is more advanced then the built in string marshelling. # We could remove our escape hack and replace the string marshalling. # >>> Marshaller.dispatch[types.StringType] = \\ Marshaller.dispatch[types.InstanceType] """ Marshaller.dispatch[types.StringType] = Marshaller.dispatch[types.InstanceType] print """ # # We could do a cleaner reimplementation, but this just show that now the str # marshaller uses the InstanceType, which I've extended to support registerring # handlers, blah, blah, blah... # >>> print dumps(('this is a test.',)) # Look ma, CDATA goodies! """ print dumps(('this is a test.', )) from mpx.lib import EnumeratedValue print dumps((EnumeratedValue(2, "asdf"), )) from mpx.lib.magnitude import MagnitudeInterface print dumps((MagnitudeInterface(1), )) print dumps((MagnitudeInterface(2L), )) print dumps((MagnitudeInterface(3.0), ))