

def _confirm_delete(self, exists, delete_events, fields):
    deleted_at = exists.get('deleted_at')
    state = exists.get('state')
    (apb, ape) = self._get_audit_period(exists)
    if ((not deleted_at) and delete_events):
        raise UsageException('U6', '.deleted events found but .exists has no deleted_at value.')
    if (deleted_at and (state != 'deleted')):
        raise UsageException('U3', ".exists state not 'deleted' but .exists deleted_at is set.")
    if (deleted_at and (not delete_events)):
        launched_at = exists.get('launched_at')
        if (deleted_at < launched_at):
            raise UsageException('U4', '.exists deleted_at < .exists launched_at.')
        if (apb and ape and (deleted_at >= apb) and (deleted_at <= ape)):
            raise UsageException('U5', '.exists deleted_at in audit period, but no matching .delete event found.')
    if (len(delete_events) > 1):
        raise UsageException('U7', 'Multiple .delete.end events')
    if delete_events:
        self._verify_fields(exists, delete_events[(- 1)], fields)

dataset/ETHPy150Open openstack/stacktach-winchester/winchester/pipeline_handler.py UsageHandler._confirm_delete/original