def touch(self, time): if type(time) is str: time = CTU.parse_time_point(time) if self.ongoing_action is None: fail('No ongoing task to touch at ' + CTU.time_point_string(time)) self.switch(self.ongoing_action[0], time)
def start(self, label, time): if type(time) is str: time = CTU.parse_time_point(time) if self.ongoing_action is not None: fail(self.ongoing_action[0] + ' already running, can\'t start ' + label + ' at ' + CTU.time_point_string(time)) self.ongoing_action = (label, time)
def stop(self, time): if type(time) is str: time = CTU.parse_time_point(time) if self.ongoing_action is None: fail('Nothing to stop (at ' + CTU.time_point_string(time) + ')') label = self.ongoing_action[0] passed_time = time - self.ongoing_action[1] if passed_time < 0: if self.allowed_leaps <= 0: fail('Not enough dayleaps for period ' + CTU.time_point_string(self.ongoing_action[1]) + ' - ' + CTU.time_point_string(time)) self.allowed_leaps -= 1 passed_time += 24 * 60 self.checkin(label, passed_time) self.ongoing_action = None
def pop_stop(self, time): if type(time) is str: time = CTU.parse_time_point(time) self.start(self.task_stack.pop(), time)
def push_stop(self, time): if type(time) is str: time = CTU.parse_time_point(time) self.task_stack.append(self.ongoing_action[0]) self.stop(time)
def push(self, label, time): if type(time) is str: time = CTU.parse_time_point(time) self.task_stack.append(self.ongoing_action[0]) self.switch(label, time)
def switch(self, label, time): if type(time) is str: time = CTU.parse_time_point(time) self.stop(time) self.start(label, time)