diff --git a/britney.py b/britney.py index ef3a8f2..c617ac0 100755 --- a/britney.py +++ b/britney.py @@ -197,7 +197,8 @@ from britney2.excuse import Excuse from britney2.hints import HintParser from britney2.installability.builder import build_installability_tester 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, compute_reverse_tree, possibly_compressed, read_nuninst, write_nuninst, write_heidi, diff --git a/britney2/policies/__init__.py b/britney2/policies/__init__.py index e69de29..37bcc9b 100644 --- a/britney2/policies/__init__.py +++ b/britney2/policies/__init__.py @@ -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, + } diff --git a/britney2/policies/policy.py b/britney2/policies/policy.py index 645a207..683b5b9 100644 --- a/britney2/policies/policy.py +++ b/britney2/policies/policy.py @@ -2,65 +2,12 @@ import json import os import time from abc import abstractmethod -from enum import Enum, unique from urllib.parse import quote import apt_pkg from britney2.hints import Hint, split_into_one_hint_per_package - - -@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, - } +from britney2.policies import PolicyVerdict class BasePolicy(object): diff --git a/britney2/utils.py b/britney2/utils.py index d54ce5b..a0fc22f 100644 --- a/britney2/utils.py +++ b/britney2/utils.py @@ -39,7 +39,7 @@ from britney2.consts import (VERSION, PROVIDES, DEPENDS, CONFLICTS, SOURCE, MAINTAINER, MULTIARCH, ESSENTIAL) from britney2.migrationitem import MigrationItem, UnversionnedMigrationItem -from britney2.policies.policy import PolicyVerdict +from britney2.policies import PolicyVerdict def ifilter_except(container, iterable=None):