File: phase.py

package info (click to toggle)
bootstrap-vz 0.9.11%2B20180121git-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,244 kB
  • sloc: python: 8,800; sh: 813; makefile: 16
file content (35 lines) | stat: -rw-r--r-- 1,042 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35


class Phase(object):
    """The Phase class represents a phase a task may be in.
    It has no function other than to act as an anchor in the task graph.
    All phases are instantiated in common.phases
    """

    def __init__(self, name, description):
        # The name of the phase
        self.name = name
        # The description of the phase (currently not used anywhere)
        self.description = description

    def pos(self):
        """Gets the position of the phase

        :return: The positional index of the phase in relation to the other phases
        :rtype: int
        """
        from bootstrapvz.common.phases import order
        return next(i for i, phase in enumerate(order) if phase is self)

    def __cmp__(self, other):
        """Compares the phase order in relation to the other phases
        :return int:
        """
        return self.pos() - other.pos()

    def __str__(self):
        """
        :return: String representation of the phase
        :rtype: str
        """
        return self.name