loadit/database.py
def check(self):
        """
        Check database integrity.

        Returns
        -------
        list of str
            List of corrupted files.
        """
        log.info('Checking database integrity...')
        files_corrupted = list()

        # Check tables integrity
        for name, header in self.header.tables.items():

            # Check table fields integrity
            for filename, hash in header['batches'][-1][2].items():
                field_file = os.path.join(self.path, name, filename)

                with open(field_file, 'rb') as f:

                    if hash != hash_bytestr(f, get_hasher(self.header.hash_function)):
                        files_corrupted.append(field_file)

            # Check table header integrity
            header_file = os.path.join(self.path, name, '#header.json')

            with open(header_file, 'rb') as f:

                if self.header.table_hashes[header['name']] != hash_bytestr(f, get_hasher(self.header.hash_function)):
                    files_corrupted.append(header_file)

        # Check attachments
        for attachment in self.header.attachments:
            attachment_file = os.path.join(self.path, '.attachments', attachment)

            with open(attachment_file, 'rb') as f:

                if self.header.attachments[attachment][0] != hash_bytestr(f, get_hasher(self.header.hash_function)):
                    files_corrupted.append(attachment_file)

        # Summary
        if files_corrupted:
            info = list()

            for file in files_corrupted:
                info.append(f"'{Path(file).relative_to(self.path).as_posix()}' is corrupted!")

            log.error('\n'.join(info))
        else:
            log.info('Everything is OK!')

        return files_corrupted

        Check database integrity.

        Returns
        -------
        list of str
            List of corrupted files.
        
Check database integrity.
Returns

list of str
List of corrupted files.
Check database integrity . Returns list of str List of corrupted files .
def check(self):
        log.info('Checking database integrity...')
        files_corrupted = list()
        for name, header in self.header.tables.items():
            for filename, hash in header['batches'][-1][2].items():
                field_file = os.path.join(self.path, name, filename)
                with open(field_file, 'rb') as f:
                    if hash != hash_bytestr(f, get_hasher(self.header.hash_function)):
                        files_corrupted.append(field_file)
            header_file = os.path.join(self.path, name, '#header.json')
            with open(header_file, 'rb') as f:
                if self.header.table_hashes[header['name']] != hash_bytestr(f, get_hasher(self.header.hash_function)):
                    files_corrupted.append(header_file)
        for attachment in self.header.attachments:
            attachment_file = os.path.join(self.path, '.attachments', attachment)
            with open(attachment_file, 'rb') as f:
                if self.header.attachments[attachment][0] != hash_bytestr(f, get_hasher(self.header.hash_function)):
                    files_corrupted.append(attachment_file)
        if files_corrupted:
            info = list()
            for file in files_corrupted:
                info.append(f"'{Path(file).relative_to(self.path).as_posix()}' is corrupted!")
            log.error('\n'.join(info))
        else:
            log.info('Everything is OK!')
        return files_corrupted
def check ( self ) : log . info ( 'Checking database integrity...' ) files_corrupted = list ( ) for name , header in self . header . tables . items ( ) : for filename , hash in header [ 'batches' ] [ - 1 ] [ 2 ] . items ( ) : field_file = os . path . join ( self . path , name , filename ) with open ( field_file , 'rb' ) as f : if hash != hash_bytestr ( f , get_hasher ( self . header . hash_function ) ) : files_corrupted . append ( field_file ) header_file = os . path . join ( self . path , name , '#header.json' ) with open ( header_file , 'rb' ) as f : if self . header . table_hashes [ header [ 'name' ] ] != hash_bytestr ( f , get_hasher ( self . header . hash_function ) ) : files_corrupted . append ( header_file ) for attachment in self . header . attachments : attachment_file = os . path . join ( self . path , '.attachments' , attachment ) with open ( attachment_file , 'rb' ) as f : if self . header . attachments [ attachment ] [ 0 ] != hash_bytestr ( f , get_hasher ( self . header . hash_function ) ) : files_corrupted . append ( attachment_file ) if files_corrupted : info = list ( ) for file in files_corrupted : info . append ( f"'{Path(file).relative_to(self.path).as_posix()}' is corrupted!" ) log . error ( '\n' . join ( info ) ) else : log . info ( 'Everything is OK!' ) return files_corrupted
Check database integrity.
Check database integrity .
"""
        Check database integrity.

        Returns
        -------
        list of str
            List of corrupted files.
        """ # Check tables integrity # Check table fields integrity # Check table header integrity # Check attachments # Summary
self