# -*- coding: utf-8 -*-
from ppms.migration.packet import *


class RemoveObsoleteExit(ChangeDTPPacket):
    '''Remove the obsolete exit 00001197 on DI 022961

    This fixes an assertion due to the fact that the exit in question is 
    obsolete since Venus.
    '''
    version = 1
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 7912

    def fix(self, runner):
        new_value = '-'
        old_value = '00001197'

        record = self.get_record(412, ['022961'], [252])
        if not record:
            return self.fail()

        if not self.change_value(record, 'exit_id', old_value, new_value):
            return self.fail()

        return self.success()
