b08ffe583f2db5092ffb84d7b1f907131ccc0aad
[portage.git] / pym / _emerge / DepPriority.py
1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 from _emerge.AbstractDepPriority import AbstractDepPriority
5 class DepPriority(AbstractDepPriority):
6
7         __slots__ = ("satisfied", "optional", "rebuild", "ignored")
8
9         def __int__(self):
10                 """
11                 Note: These priorities are only used for measuring hardness
12                 in the circular dependency display via digraph.debug_print(),
13                 and nothing more. For actual merge order calculations, the
14                 measures defined by the DepPriorityNormalRange and
15                 DepPrioritySatisfiedRange classes are used.
16
17                 Attributes                            Hardness
18
19                 buildtime                               0
20                 runtime                                -1
21                 runtime_post                           -2
22                 optional                               -3
23                 (none of the above)                    -4
24
25                 """
26
27                 if self.optional:
28                         return -3
29                 if self.buildtime:
30                         return 0
31                 if self.runtime:
32                         return -1
33                 if self.runtime_post:
34                         return -2
35                 return -4
36
37         def __str__(self):
38                 if self.ignored:
39                         return "ignored"
40                 if self.optional:
41                         return "optional"
42                 if self.buildtime:
43                         return "buildtime"
44                 if self.runtime:
45                         return "runtime"
46                 if self.runtime_post:
47                         return "runtime_post"
48                 return "soft"
49