Changeset 1fd7029 in flowtimer


Ignore:
Timestamp:
08/22/24 00:01:54 (9 months ago)
Author:
Enrico Schwass <ennoausberlin@…>
Branches:
guix
Children:
8fb44c2
Parents:
44c3377
Message:

title added to RecurringPhaseSequence

File:
1 edited

Legend:

Unmodified
Added
Removed
  • flowtimer/RecurringPhaseSequence.py

    r44c3377 r1fd7029  
    1212                return Phase(d['title'], d['initial_ticks'])
    1313            if 'phase_list' in d and 'initial_repetitions' in d:
    14                 return RecurringPhaseSequence(d['phase_list'], d['initial_repetitions'])
     14                return RecurringPhaseSequence(d["title"], d['phase_list'], d['initial_repetitions'])
     15            print("Wrong format")
    1516            return d
    1617        return json.loads(a_json_string, object_hook=custom_object_hook)
     
    1819    @classmethod
    1920    def default_json_string(cls):
    20         return json.dumps({"phase_list": [{"title": "Huddle", "initial_ticks": 10},
     21        return json.dumps({"title": "default",
     22                           "phase_list": [{"title": "Huddle", "initial_ticks": 10},
    2123                                          {"title": "Tasking", "initial_ticks": 5},
    2224                                          {"title": "Work", "initial_ticks": 45},
     
    2830        return cls.from_json(cls.default_json_string())
    2931
    30     def __init__(self, phase_list, repetitions):
     32    def __init__(self, title, phase_list, repetitions):
    3133        assert repetitions > 0
    3234        assert phase_list is not []
     35        self._title = title
    3336        self.state = "initial"
    3437        self.phase_list = phase_list
     
    4043        return json.dumps(self.__dict__, default=lambda each: each.to_json())
    4144
     45    @property
    4246    def title(self):
    43         return self.current_phase.title
     47        return self._title
    4448
    4549    def current_phase_number(self):
     
    5357            return self.phase_list[self.current_phase_number()+1:]
    5458        return []
     59
     60    @property
     61    def initial_ticks(self):
     62        return sum([each.initial_ticks for each in self.phase_list])
    5563
    5664    @property
     
    6775        self.current_phase.abort()
    6876        self.state = "finished"
     77
     78    def start(self):
     79        self.state = "running"
    6980
    7081    def tick(self, ticks):
Note: See TracChangeset for help on using the changeset viewer.