コード例 #1
0
    def getTime(self):
        """Read the next Time value off the session."""
        typeCode = self._getTypeCode()

        if typeCode in range(protocol.MILLISECLEN0, protocol.MILLISECLEN8 + 1):
            return fromSignedByteString(self._takeBytes(typeCode - 86))

        if typeCode in range(protocol.NANOSECLEN0, protocol.NANOSECLEN8 + 1):
            return fromSignedByteString(self._takeBytes(typeCode - 95))

        if typeCode in range(protocol.TIMELEN0, protocol.TIMELEN4 + 1):
            return fromByteString(self._takeBytes(typeCode - 104))

        raise DataError('Not a time')
コード例 #2
0
ファイル: encodedsession.py プロジェクト: jgetto/nuodb-python
 def getTime(self):
     """Read the next Time value off the session."""
     typeCode = self._getTypeCode()
     
     if typeCode in range(protocol.MILLISECLEN0, protocol.MILLISECLEN8 + 1):
         return fromSignedByteString(self._takeBytes(typeCode - 86))
         
     if typeCode in range(protocol.NANOSECLEN0, protocol.NANOSECLEN8 + 1):
         return fromSignedByteString(self._takeBytes(typeCode - 95))
         
     if typeCode in range(protocol.TIMELEN0, protocol.TIMELEN4 + 1):
         return fromByteString(self._takeBytes(typeCode - 104))
         
     raise DataError('Not a time')
コード例 #3
0
ファイル: encodedsession.py プロジェクト: jgetto/nuodb-python
    def getScaledDate(self):
        """Read the next Scaled Date value off the session."""
        typeCode = self._getTypeCode()

        if typeCode in range(protocol.SCALEDDATELEN1, protocol.SCALEDDATELEN8 + 1):
            scale = fromByteString(self._takeBytes(1))
            date = fromSignedByteString(self._takeBytes(typeCode - 200))
            return datatype.DateFromTicks(round(date/10.0**scale))

        raise DataError('Not a scaled date')
コード例 #4
0
    def getScaledInt(self):
        """Read the next Scaled Integer value off the session."""
        typeCode = self._getTypeCode()

        if typeCode in range(protocol.SCALEDLEN0, protocol.SCALEDLEN8 + 1):
            scale = fromByteString(self._takeBytes(1))
            value = fromSignedByteString(self._takeBytes(typeCode - 60))
            return decimal.Decimal(value) / decimal.Decimal(10**scale)

        raise DataError('Not a scaled integer')
コード例 #5
0
    def getScaledInt(self):
        """Read the next Scaled Integer value off the session."""
        typeCode = self._getTypeCode()

        if typeCode in range(protocol.SCALEDLEN0, protocol.SCALEDLEN8 + 1):
            scale = fromByteString(self._takeBytes(1))
            value = fromSignedByteString(self._takeBytes(typeCode - 60))
            return decimal.Decimal(value) / decimal.Decimal(10**scale)

        raise DataError('Not a scaled integer')
コード例 #6
0
ファイル: encodedsession.py プロジェクト: jgetto/nuodb-python
    def getScaledTimestamp(self):
        """Read the next Scaled Timestamp value off the session."""
        typeCode = self._getTypeCode()

        if typeCode in range(protocol.SCALEDTIMESTAMPLEN1, protocol.SCALEDTIMESTAMPLEN8 + 1):
            scale = fromByteString(self._takeBytes(1))
            timestamp = fromSignedByteString(self._takeBytes(typeCode - 216))
            ticks = decimal.Decimal(str(timestamp)) / decimal.Decimal(10**scale)
            return datatype.TimestampFromTicks(round(int(ticks)), int((ticks % 1) * decimal.Decimal(1000000)))

        raise DataError('Not a scaled timestamp')
コード例 #7
0
ファイル: encodedsession.py プロジェクト: jgetto/nuodb-python
    def getInt(self):
        """Read the next Integer value off the session."""
        typeCode = self._getTypeCode()

        if typeCode in range(protocol.INTMINUS10, protocol.INT31 + 1):
            return typeCode - 20

        elif typeCode in range(protocol.INTLEN1, protocol.INTLEN8 + 1):
            return fromSignedByteString(self._takeBytes(typeCode - 51))

        raise DataError('Not an integer')
コード例 #8
0
    def getScaledDate(self):
        """Read the next Scaled Date value off the session."""
        typeCode = self._getTypeCode()

        if typeCode in range(protocol.SCALEDDATELEN1,
                             protocol.SCALEDDATELEN8 + 1):
            scale = fromByteString(self._takeBytes(1))
            date = fromSignedByteString(self._takeBytes(typeCode - 200))
            return datatype.DateFromTicks(round(date / 10.0**scale))

        raise DataError('Not a scaled date')
コード例 #9
0
    def getInt(self):
        """Read the next Integer value off the session."""
        typeCode = self._getTypeCode()

        if typeCode in range(protocol.INTMINUS10, protocol.INT31 + 1):
            return typeCode - 20

        elif typeCode in range(protocol.INTLEN1, protocol.INTLEN8 + 1):
            return fromSignedByteString(self._takeBytes(typeCode - 51))

        raise DataError('Not an integer')
コード例 #10
0
ファイル: encodedsession.py プロジェクト: jgetto/nuodb-python
    def getScaledInt(self):
        """Read the next Scaled Integer value off the session."""
        typeCode = self._getTypeCode()

        if typeCode in range(protocol.SCALEDLEN0, protocol.SCALEDLEN8 + 1):
            scale = fromByteString(self._takeBytes(1))
            value = fromSignedByteString(self._takeBytes(typeCode - 60))
            # preserves Decimal sign, exp, int...
            sign = 1 if value < 0 else 0
            value = tuple(int(i) for i in str(abs(value)))
            return decimal.Decimal((sign, value, -1 * scale))

        raise DataError('Not a scaled integer')
コード例 #11
0
    def getScaledTimestamp(self):
        """Read the next Scaled Timestamp value off the session."""
        typeCode = self._getTypeCode()

        if typeCode in range(protocol.SCALEDTIMESTAMPLEN1,
                             protocol.SCALEDTIMESTAMPLEN8 + 1):
            scale = fromByteString(self._takeBytes(1))
            timestamp = fromSignedByteString(self._takeBytes(typeCode - 216))
            ticks = decimal.Decimal(str(timestamp)) / decimal.Decimal(10**
                                                                      scale)
            return datatype.TimestampFromTicks(
                round(int(ticks)), int((ticks % 1) * decimal.Decimal(1000000)))

        raise DataError('Not a scaled timestamp')