stalker.models.mixins.ScheduleMixin¶
-
class
stalker.models.mixins.
ScheduleMixin
(schedule_timing=None, schedule_unit=None, schedule_model=None, schedule_constraint=0, **kwargs)[source]¶ Bases:
object
Adds schedule info to the mixed in class.
Adds attributes like schedule_timing, schedule_unit and schedule_model attributes to the mixed in class.
Use the
__default_schedule_attr_name__
attribute to customize the column names.-
__init__
(schedule_timing=None, schedule_unit=None, schedule_model=None, schedule_constraint=0, **kwargs)[source]¶
Methods
__init__
([schedule_timing, schedule_unit, …])least_meaningful_time_unit
(seconds[, …])returns the least meaningful timing unit that corresponds to the to_seconds
(timing, unit, model)converts the schedule values to seconds, depending on to the Attributes
schedule_constraint
schedule_model
schedule_seconds
Returns the schedule values as seconds, depending on to the schedule_model the value will differ. schedule_timing
schedule_unit
-
classmethod
least_meaningful_time_unit
(seconds, as_work_time=True)[source]¶ returns the least meaningful timing unit that corresponds to the given seconds. So if:
- as_work_time == True
- seconds % (1 years work time as seconds) == 0 –> ‘y’ else: seconds % (1 month work time as seconds) == 0 –> ‘m’ else: seconds % (1 week work time as seconds) == 0 –> ‘w’ else: seconds % (1 day work time as seconds) == 0 –> ‘d’ else: seconds % (1 hour work time as seconds) == 0 –> ‘h’ else: seconds % (1 minutes work time as seconds) == 0 –> ‘min’ else: raise RuntimeError
- as_work_time == False
- seconds % (1 years as seconds) == 0 –> ‘y’ else: seconds % (1 month as seconds) == 0 –> ‘m’ else: seconds % (1 week as seconds) == 0 –> ‘w’ else: seconds % (1 day as seconds) == 0 –> ‘d’ else: seconds % (1 hour as seconds) == 0 –> ‘h’ else: seconds % (1 minutes as seconds) == 0 –> ‘min’ else: raise RuntimeError
Parameters: Returns int, string: Returns one integer and one string, showing the timing value and the unit.
-
classmethod
to_seconds
(timing, unit, model)[source]¶ converts the schedule values to seconds, depending on to the schedule_model the value will differ. So if the schedule_model is ‘effort’ or ‘length’ then the schedule_time and schedule_unit values are interpreted as work time, if the schedule_model is ‘duration’ then the schedule_time and schedule_unit values are considered as calendar time.
-
schedule_seconds
¶ Returns the schedule values as seconds, depending on to the schedule_model the value will differ. So if the schedule_model is ‘effort’ or ‘length’ then the schedule_time and schedule_unit values are interpreted as work time, if the schedule_model is ‘duration’ then the schedule_time and schedule_unit values are considered as calendar time.
-