loadit/database.py
def add_attachment(self, file, copy=True):
        """
        Add a new attachment (consisting on one or more files) to the database.

        Parameters
        ----------
        file : str
            Attachment file path.
        copy : bool
            Whether to copy or not the file.
        """
        name = os.path.basename(file)

        if name in self.header.attachments:
            raise FileExistsError(f"Already existing attachment!")

        attachment_file = os.path.join(self.path, '.attachments', name)

        if copy:
            shutil.copyfile(file, attachment_file)
        else:
            os.rename(file, attachment_file)

        with open(attachment_file, 'rb') as f:
            self.header.attachments[name] = [hash_bytestr(f, get_hasher(self.header.hash_function)),
                                             os.path.getsize(attachment_file)]

        self._write_header()
        log.info(f"Attachment '{name}' added")

        Add a new attachment (consisting on one or more files) to the database.

        Parameters
        ----------
        file : str
            Attachment file path.
        copy : bool
            Whether to copy or not the file.
        
Add a new attachment (consisting on one or more files) to the database.
Parameters

file : str
Attachment file path.
copy : bool
Whether to copy or not the file.
Add a new attachment ( consisting on one or more files ) to the database . Parameters file : str Attachment file path . copy : bool Whether to copy or not the file .
def add_attachment(self, file, copy=True):
        name = os.path.basename(file)
        if name in self.header.attachments:
            raise FileExistsError(f"Already existing attachment!")
        attachment_file = os.path.join(self.path, '.attachments', name)
        if copy:
            shutil.copyfile(file, attachment_file)
        else:
            os.rename(file, attachment_file)
        with open(attachment_file, 'rb') as f:
            self.header.attachments[name] = [hash_bytestr(f, get_hasher(self.header.hash_function)),
                                             os.path.getsize(attachment_file)]
        self._write_header()
        log.info(f"Attachment '{name}' added")
def add_attachment ( self , file , copy = True ) : name = os . path . basename ( file ) if name in self . header . attachments : raise FileExistsError ( f"Already existing attachment!" ) attachment_file = os . path . join ( self . path , '.attachments' , name ) if copy : shutil . copyfile ( file , attachment_file ) else : os . rename ( file , attachment_file ) with open ( attachment_file , 'rb' ) as f : self . header . attachments [ name ] = [ hash_bytestr ( f , get_hasher ( self . header . hash_function ) ) , os . path . getsize ( attachment_file ) ] self . _write_header ( ) log . info ( f"Attachment '{name}' added" )
Add a new attachment (consisting on one or more files) to the database.
Add a new attachment ( consisting on one or more files ) to the database .
"""
        Add a new attachment (consisting on one or more files) to the database.

        Parameters
        ----------
        file : str
            Attachment file path.
        copy : bool
            Whether to copy or not the file.
        """
self
file
copy