Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(14)  |  Call(12)  |  Derive(0)  |  Import(2)

        def toSignedByteString(value):
    if value == 0 or value == -1:
        return chr(value & 0xFF)
    
    resultBytes = []
    while value != 0 and value != -1:
        resultBytes.append(chr(value & 0xFF))
        value >>= 8
            
        # Zero pad if positive
    if value == 0 and (ord(resultBytes[-1]) & 0x80) == 0x80:
        resultBytes.append(chr(0x00))
    elif value == -1 and (ord(resultBytes[-1]) & 0x80) == 0x00:
        resultBytes.append(chr(0xFF))
    
    resultBytes.reverse();
    result = ''.join(resultBytes)
    
    return result
        


src/p/y/pynuodb-2.1/pynuodb/encodedsession.py   pynuodb(Download)
__all__  = [ 'EncodedSession' ]
 
from crypt import toByteString, fromByteString, toSignedByteString, fromSignedByteString
from session import Session, SessionException
 
                valueStr = toByteString(value)
            else:
                valueStr = toSignedByteString(value)
            packed = chr(protocol.INTLEN1 - 1 + len(valueStr)) + valueStr
        self.__output += packed
        """
        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
    def putMsSinceEpoch(self, value):
        """Appends the MsSinceEpoch value to the message."""
        valueStr = toSignedByteString(value)
        packed = chr(protocol.MILLISECLEN0 + len(valueStr)) + valueStr
        self.__output += packed
        return self
 
    def putNsSinceEpoch(self, value):
        """Appends the NsSinceEpoch value to the message."""
        valueStr = toSignedByteString(value)

src/n/u/nuodb-python-HEAD/pynuodb/encodedsession.py   nuodb-python(Download)
__all__  = [ 'EncodedSession' ]
 
from crypt import toByteString, fromByteString, toSignedByteString, fromSignedByteString
from session import Session, SessionException
 
                valueStr = toByteString(value)
            else:
                valueStr = toSignedByteString(value)
            packed = chr(protocol.INTLEN1 - 1 + len(valueStr)) + valueStr
        self.__output += packed
        """
        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
    def putMsSinceEpoch(self, value):
        """Appends the MsSinceEpoch value to the message."""
        valueStr = toSignedByteString(value)
        packed = chr(protocol.MILLISECLEN0 + len(valueStr)) + valueStr
        self.__output += packed
        return self
 
    def putNsSinceEpoch(self, value):
        """Appends the NsSinceEpoch value to the message."""
        valueStr = toSignedByteString(value)