Move PolicyVerdict to britney2.policies

ubuntu/rebased
Niels Thykier 7 years ago
parent 784d80ab4c
commit c537f0554f

@ -197,7 +197,8 @@ from britney2.excuse import Excuse
from britney2.hints import HintParser from britney2.hints import HintParser
from britney2.installability.builder import build_installability_tester from britney2.installability.builder import build_installability_tester
from britney2.migrationitem import MigrationItem from britney2.migrationitem import MigrationItem
from britney2.policies.policy import AgePolicy, RCBugPolicy, PiupartsPolicy, PolicyVerdict from britney2.policies import PolicyVerdict
from britney2.policies.policy import AgePolicy, RCBugPolicy, PiupartsPolicy
from britney2.utils import (old_libraries_format, undo_changes, from britney2.utils import (old_libraries_format, undo_changes,
compute_reverse_tree, possibly_compressed, compute_reverse_tree, possibly_compressed,
read_nuninst, write_nuninst, write_heidi, read_nuninst, write_nuninst, write_heidi,

@ -0,0 +1,53 @@
from enum import Enum, unique
@unique
class PolicyVerdict(Enum):
""""""
"""
The migration item passed the policy.
"""
PASS = 1
"""
The policy was completely overruled by a hint.
"""
PASS_HINTED = 2
"""
The migration item did not pass the policy, but the failure is believed
to be temporary
"""
REJECTED_TEMPORARILY = 3
"""
The migration item is temporarily unable to migrate due to another item. The other item is temporarily blocked.
"""
REJECTED_WAITING_FOR_ANOTHER_ITEM = 4
"""
The migration item is permanently unable to migrate due to another item. The other item is permanently blocked.
"""
REJECTED_BLOCKED_BY_ANOTHER_ITEM = 5
"""
The migration item needs approval to migrate
"""
REJECTED_NEEDS_APPROVAL = 6
"""
The migration item is blocked, but there is not enough information to determine
if this issue is permanent or temporary
"""
REJECTED_CANNOT_DETERMINE_IF_PERMANENT = 7
"""
The migration item did not pass the policy and the failure is believed
to be uncorrectable (i.e. a hint or a new version is needed)
"""
REJECTED_PERMANENTLY = 8
@property
def is_rejected(self):
return True if self.name.startswith('REJECTED') else False
def is_blocked(self):
"""Whether the item (probably) needs a fix or manual assistance to migrate"""
return self in {
PolicyVerdict.REJECTED_BLOCKED_BY_ANOTHER_ITEM,
PolicyVerdict.REJECTED_NEEDS_APPROVAL,
PolicyVerdict.REJECTED_CANNOT_DETERMINE_IF_PERMANENT, # Assuming the worst
PolicyVerdict.REJECTED_PERMANENTLY,
}

@ -2,65 +2,12 @@ import json
import os import os
import time import time
from abc import abstractmethod from abc import abstractmethod
from enum import Enum, unique
from urllib.parse import quote from urllib.parse import quote
import apt_pkg import apt_pkg
from britney2.hints import Hint, split_into_one_hint_per_package from britney2.hints import Hint, split_into_one_hint_per_package
from britney2.policies import PolicyVerdict
@unique
class PolicyVerdict(Enum):
""""""
"""
The migration item passed the policy.
"""
PASS = 1
"""
The policy was completely overruled by a hint.
"""
PASS_HINTED = 2
"""
The migration item did not pass the policy, but the failure is believed
to be temporary
"""
REJECTED_TEMPORARILY = 3
"""
The migration item is temporarily unable to migrate due to another item. The other item is temporarily blocked.
"""
REJECTED_WAITING_FOR_ANOTHER_ITEM = 4
"""
The migration item is permanently unable to migrate due to another item. The other item is permanently blocked.
"""
REJECTED_BLOCKED_BY_ANOTHER_ITEM = 5
"""
The migration item needs approval to migrate
"""
REJECTED_NEEDS_APPROVAL = 6
"""
The migration item is blocked, but there is not enough information to determine
if this issue is permanent or temporary
"""
REJECTED_CANNOT_DETERMINE_IF_PERMANENT = 7
"""
The migration item did not pass the policy and the failure is believed
to be uncorrectable (i.e. a hint or a new version is needed)
"""
REJECTED_PERMANENTLY = 8
@property
def is_rejected(self):
return True if self.name.startswith('REJECTED') else False
def is_blocked(self):
"""Whether the item (probably) needs a fix or manual assistance to migrate"""
return self in {
PolicyVerdict.REJECTED_BLOCKED_BY_ANOTHER_ITEM,
PolicyVerdict.REJECTED_NEEDS_APPROVAL,
PolicyVerdict.REJECTED_CANNOT_DETERMINE_IF_PERMANENT, # Assuming the worst
PolicyVerdict.REJECTED_PERMANENTLY,
}
class BasePolicy(object): class BasePolicy(object):

@ -39,7 +39,7 @@ from britney2.consts import (VERSION, PROVIDES, DEPENDS, CONFLICTS,
SOURCE, MAINTAINER, MULTIARCH, SOURCE, MAINTAINER, MULTIARCH,
ESSENTIAL) ESSENTIAL)
from britney2.migrationitem import MigrationItem, UnversionnedMigrationItem from britney2.migrationitem import MigrationItem, UnversionnedMigrationItem
from britney2.policies.policy import PolicyVerdict from britney2.policies import PolicyVerdict
def ifilter_except(container, iterable=None): def ifilter_except(container, iterable=None):

Loading…
Cancel
Save