2013-06-23 15:26:08 +02:00
|
|
|
|
|
|
|
|
2013-06-23 22:12:29 +02:00
|
|
|
class Phase(object):
|
2014-03-23 16:04:03 +01:00
|
|
|
"""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
|
|
|
|
"""
|
2014-03-23 19:37:25 +01:00
|
|
|
|
2013-08-11 18:25:05 +02:00
|
|
|
def __init__(self, name, description):
|
2014-03-23 16:04:03 +01:00
|
|
|
# The name of the phase
|
2013-08-11 18:25:05 +02:00
|
|
|
self.name = name
|
2014-03-23 16:04:03 +01:00
|
|
|
# The description of the phase (currently not used anywhere)
|
2013-06-23 22:12:29 +02:00
|
|
|
self.description = description
|
2013-06-23 15:26:08 +02:00
|
|
|
|
2013-06-23 22:12:29 +02:00
|
|
|
def pos(self):
|
2014-03-23 16:04:03 +01:00
|
|
|
"""Gets the position of the phase
|
2014-03-23 19:37:25 +01:00
|
|
|
|
2014-05-04 19:31:53 +02:00
|
|
|
:return: The positional index of the phase in relation to the other phases
|
|
|
|
:rtype: int
|
2014-03-23 16:04:03 +01:00
|
|
|
"""
|
2014-03-23 23:12:07 +01:00
|
|
|
from bootstrapvz.common.phases import order
|
2014-01-12 12:46:59 +01:00
|
|
|
return next(i for i, phase in enumerate(order) if phase is self)
|
2013-06-23 17:54:25 +02:00
|
|
|
|
2013-06-23 22:12:29 +02:00
|
|
|
def __cmp__(self, other):
|
2014-03-23 16:04:03 +01:00
|
|
|
"""Compares the phase order in relation to the other phases
|
2014-05-04 19:31:53 +02:00
|
|
|
:return int:
|
2014-03-23 16:04:03 +01:00
|
|
|
"""
|
2013-06-23 22:12:29 +02:00
|
|
|
return self.pos() - other.pos()
|
2013-06-23 15:26:08 +02:00
|
|
|
|
|
|
|
def __str__(self):
|
2014-05-04 19:31:53 +02:00
|
|
|
"""
|
|
|
|
:return: String representation of the phase
|
|
|
|
:rtype: str
|
2014-03-23 16:04:03 +01:00
|
|
|
"""
|
2013-08-11 18:25:05 +02:00
|
|
|
return self.name
|