def decode(self, buf):
        """
        Set object attributes from binary string buffer.
        
        :param buf: The binary string representation of this struct from database.
        :type buf: bytes 
        """
        index = 0
        if self.length > len(buf):
            raise exc.ParseError("Insufficient data for reading header.") 
        for (name, nbytes, typecode) in self.format:
            string = buf[index:index + nbytes]
            index += nbytes
            value = struct.unpack('<' + typecode, string)[0]
            setattr(self, name, value)
        if const.DB_SIGNATURE1 != self.signature1 or \
                const.DB_SIGNATURE2 != self.signature2:
            msg = 'Bad signatures: {0} {0}'.format(hex(self.signature1),
                                                   hex(self.signature2))
            raise exc.InvalidDatabase(msg)
def decode ( self , buf ) : index = 0 if self . length > len ( buf ) : raise exc . ParseError ( "Insufficient data for reading header." ) for ( name , nbytes , typecode ) in self . format : string = buf [ index : index + nbytes ] index += nbytes value = struct . unpack ( '<' + typecode , string ) [ 0 ] setattr ( self , name , value ) if const . DB_SIGNATURE1 != self . signature1 or const . DB_SIGNATURE2 != self . signature2 : msg = 'Bad signatures: {0} {0}' . format ( hex ( self . signature1 ) , hex ( self . signature2 ) ) raise exc . InvalidDatabase ( msg )
Set object attributes from binary string buffer.
        
        :param buf: The binary string representation of this struct from database.
        :type buf: bytes