예제 #1
0
 def putScaledInt(self, value):
     """Appends a Scaled Integer value to the message."""
     scale = abs(value.as_tuple()[2])
     valueStr = toSignedByteString(int(value * decimal.Decimal(10**scale)))
     packed = chr(protocol.SCALEDLEN0 + len(valueStr)) + chr(scale) + valueStr
     self.__output += packed
     return self
예제 #2
0
 def putScaledDate(self, value):
     """Appends a Scaled Date value to the message."""
     ticks = datatype.DateToTicks(value)
     valueStr = toSignedByteString(ticks)
     if len(valueStr) == 0:
         packed = chr(protocol.SCALEDDATELEN1) + chr(0) + chr(0)
     else:  
         packed = chr(protocol.SCALEDDATELEN1 - 1 + len(valueStr)) + chr(0) + valueStr
     self.__output += packed
     return self
예제 #3
0
 def putScaledTimestamp(self, value):
     """Appends a Scaled Timestamp value to the message."""
     (ticks, scale) = datatype.TimestampToTicks(value)
     valueStr = toSignedByteString(ticks)
     if len(valueStr) == 0:
         packed = chr(protocol.SCALEDTIMESTAMPLEN1) + chr(0) + chr(0)
     else:
         packed = chr(protocol.SCALEDTIMESTAMPLEN1 - 1 + len(valueStr)) + chr(scale) + valueStr
     self.__output += packed
     return self
예제 #4
0
 def putScaledDate(self, value):
     """Appends a Scaled Date value to the message."""
     ticks = datatype.DateToTicks(value)
     valueStr = toSignedByteString(ticks)
     if len(valueStr) == 0:
         packed = chr(protocol.SCALEDDATELEN1) + chr(0) + chr(0)
     else:
         packed = chr(protocol.SCALEDDATELEN1 - 1 +
                      len(valueStr)) + chr(0) + valueStr
     self.__output += packed
     return self
예제 #5
0
 def putScaledTimestamp(self, value):
     """Appends a Scaled Timestamp value to the message."""
     (ticks, scale) = datatype.TimestampToTicks(value)
     valueStr = toSignedByteString(ticks)
     if len(valueStr) == 0:
         packed = chr(protocol.SCALEDTIMESTAMPLEN1) + chr(0) + chr(0)
     else:
         packed = chr(protocol.SCALEDTIMESTAMPLEN1 - 1 +
                      len(valueStr)) + chr(scale) + valueStr
     self.__output += packed
     return self
예제 #6
0
 def putScaledInt(self, value):
     """
     Appends a Scaled Integer value to the message.
     @type value decimal.Decimal
     """
     scale = abs(value.as_tuple()[2])
     valueStr = toSignedByteString(int(value * decimal.Decimal(10**scale)))
     packed = chr(protocol.SCALEDLEN0 +
                  len(valueStr)) + chr(scale) + valueStr
     self.__output += packed
     return self
예제 #7
0
 def putInt(self, value, isMessageId = False):
     """Appends an Integer value to the message."""
     if value < 32 and value > -11:
         packed = chr(protocol.INT0 + value)
     else:
         if isMessageId:
             valueStr = toByteString(value)
         else:
             valueStr = toSignedByteString(value)
         packed = chr(protocol.INTLEN1 - 1 + len(valueStr)) + valueStr
     self.__output += packed
     return self
예제 #8
0
 def putInt(self, value, isMessageId=False):
     """
     Appends an Integer value to the message.
     @type value int
     @type isMessageId bool
     """
     if value < 32 and value > -11:
         packed = chr(protocol.INT0 + value)
     else:
         if isMessageId:
             valueStr = toByteString(value)
         else:
             valueStr = toSignedByteString(value)
         packed = chr(protocol.INTLEN1 - 1 + len(valueStr)) + valueStr
     self.__output += packed
     return self
예제 #9
0
 def putNsSinceEpoch(self, value):
     """Appends the NsSinceEpoch value to the message."""
     valueStr = toSignedByteString(value)
     packed = chr(protocol.NANOSECLEN0 + len(valueStr)) + valueStr
     self.__output += packed
     return self
예제 #10
0
 def putNsSinceEpoch(self, value):
     """Appends the NsSinceEpoch value to the message."""
     valueStr = toSignedByteString(value)
     packed = chr(protocol.NANOSECLEN0 + len(valueStr)) + valueStr
     self.__output += packed
     return self