stalker.models.mixins.ScheduleMixin

Inheritance diagram of stalker.models.mixins.ScheduleMixin
class stalker.models.mixins.ScheduleMixin(schedule_timing=None, schedule_unit=None, schedule_model=None, schedule_constraint=0, **kwargs)

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)

x.__init__(…) initializes x; see help(type(x)) for signature

Methods

__init__([schedule_timing, schedule_unit, …]) x.__init__(…) initializes x; see help(type(x)) for signature
least_meaningful_time_unit(seconds[, …]) returns the least meaningful timing unit that corresponds to the given seconds.
to_seconds(timing, unit, model) converts the schedule values to seconds, depending on to the schedule_model the value will differ.

Attributes

defaults
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)

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:
  • seconds (int) – An integer showing the total seconds to be converted.
  • as_work_time (bool) – Should the input be considered as work time or calendar time.
Returns int, string:
 

Returns one integer and one string, showing the timing value and the unit.

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.

classmethod to_seconds(timing, unit, model)

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.