示例#1
0
def parse_record(record_hex_string):
    # parse the record header
    _adel_log.log(
        "parse_record:                  ----> parsing record header....", 4)
    header_length_tuple = _sqliteVarInt.parse_next_var_int(
        record_hex_string[0:18])
    header_string = record_hex_string[(header_length_tuple[1] *
                                       2):(header_length_tuple[0] * 2)]
    record_header_field_list = _sqliteVarInt.parse_all_var_ints(header_string)
    _adel_log.log(
        "parse_record:                        OK - record header field list is %(record_header_field_list)s"
        % vars(), 4)

    # Get the record content
    content_offset = header_length_tuple[0] * 2
    content_list = []
    element = 0
    for var_int in record_header_field_list:
        entry_content = parse_content_entry(record_header_field_list[element],
                                            record_hex_string, content_offset)
        content_list.append(entry_content[0])
        content_offset += entry_content[1] * 2
        element += 1

    # Return the record content list
    _adel_log.log(
        "parse_record:                        OK - returning list of record contents",
        4)  #: %(content_list)s" %vars(), 4)
    _adel_log.log("parse_record:                  ----> record header parsed",
                  4)
    return content_list
示例#2
0
    def getCellData(self, cell):
        #hexdump(cell)

        header, size = self.cell_header(cell)
        celltype = cell[size:size + header[2] - 2]
        celldata = cell[size + header[2] - 2:size + header[0]]
        #hexdump(celldata)

        #print 'size: %x, %x'%(size, size+header[2]-2)
        offset = 0
        dataset = []
        column = []
        record = []

        if header[0] == 0x00 or header[2] == 0x00 or len(celldata) == 0:
            if len(column) != 0 and len(record) != 0:
                dataset.append(column)
                dataset.append(record)
            return dataset

        typehexstr = binascii.hexlify(celltype)
        typelist = _sqliteVarInt.parse_all_var_ints(typehexstr)

        #print typelist

        for byte in typelist:
            typensize = self.check_type(byte)
            if typensize[0] == 'Unknown':  # NULL SECTION
                column.append('Unknown')  # column list
                record.append(0)
            else:
                #print 'type: %s, size: %i'%(typensize[0], typensize[1])
                data = self.getData(celldata, typensize[0], typensize[1],
                                    offset)
                offset += typensize[1]

                column.append(typensize[0])  # column list
                record.append(data)
        if len(column) != 0 and len(record) != 0:
            dataset.append(column)
            dataset.append(record)

        return dataset
示例#3
0
    def getCellData(self, cell):
        #hexdump(cell)

        header, size = self.cell_header(cell)
        celltype = cell[size:size + header[2] - 2]
        celldata = cell[size + header[2] - 2:size + header[0]]
        #hexdump(celldata)

        #print 'size: %x, %x'%(size, size+header[2]-2)
        offset = 0
        dataset = []
        column = []
        record = []

        if header[0] == 0x00 or header[2] == 0x00 or len(celldata) == 0:
            if len(column) != 0 and len(record) != 0:
                dataset.append(column)
                dataset.append(record)
            return dataset

        typehexstr = binascii.hexlify(celltype)
        typelist = _sqliteVarInt.parse_all_var_ints(typehexstr)

        #print typelist

        for byte in typelist:
            typensize = self.check_type(byte)
            if typensize[0] == 'Unknown': # NULL SECTION
                column.append('Unknown')  # column list
                record.append(0)
            else:
                #print 'type: %s, size: %i'%(typensize[0], typensize[1])
                data = self.getData(celldata, typensize[0], typensize[1], offset)
                offset += typensize[1]

                column.append(typensize[0])  # column list
                record.append(data)
        if len(column) != 0 and len(record) != 0:
            dataset.append(column)
            dataset.append(record)

        return dataset
示例#4
0
def parse_record(record_hex_string):
    # parse the record header
    _adel_log.log("parse_record:                  ----> parsing record header....", 4)
    header_length_tuple = _sqliteVarInt.parse_next_var_int(record_hex_string[0:18])
    header_string = record_hex_string[(header_length_tuple[1] * 2):(header_length_tuple[0] * 2)]
    record_header_field_list = _sqliteVarInt.parse_all_var_ints(header_string)
    _adel_log.log("parse_record:                        OK - record header field list is %(record_header_field_list)s" % vars(), 4)

    # Get the record content
    content_offset = header_length_tuple[0] * 2
    content_list = []
    element = 0
    for var_int in record_header_field_list:
        entry_content = parse_content_entry(record_header_field_list[element], record_hex_string, content_offset)
        content_list.append(entry_content[0])
        content_offset += entry_content[1] * 2
        element += 1

    # Return the record content list
    _adel_log.log("parse_record:                        OK - returning list of record contents", 4)#: %(content_list)s" %vars(), 4)
    _adel_log.log("parse_record:                  ----> record header parsed", 4)
    return content_list