<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def update_attachment(self, volumeID, attachmentID, metadata):
        '''update an existing attachment

        the given metadata dict will be merged with the old one.
        only the following fields could be updated:
        [name, mime, notes, download_count]
        '''
        log.debug('updating metadata of attachment {} from volume {}'.format(attachmentID, volumeID))
        modifiable_fields = ['name', 'mime', 'notes', 'download_count']
        for k in metadata.keys():
            if k not in modifiable_fields:
                raise ValueError('Not modifiable field given: {}'.format(k))
        if 'name' in metadata and not isinstance(metadata['name'], basestring):
            raise ValueError("'name' must be a string")
        if 'mime' in metadata and not isinstance(metadata['mime'], basestring):
            raise ValueError("'mime' must be a string")
        if 'notes' in metadata and not isinstance(metadata['notes'], basestring):
            raise ValueError("'notes' must be a string")
        if 'download_count' in metadata and not isinstance(metadata['download_count'], Integral):
            raise ValueError("'download_count' must be a number")
        rawVolume = self._req_raw_volume(volumeID)
        for attachment in rawVolume['_source']['_attachments']:
            if attachment['id'] == attachmentID:
                attachment.update(metadata)
                self._db.modify_book(id=volumeID, body=rawVolume['_source'], version=rawVolume['_version'])
                return
        raise NotFoundException('Could not found attachment with id {} in volume {}'.format(attachmentID, volumeID))