Changeset 1fd7029 in flowtimer
- Timestamp:
- 08/22/24 00:01:54 (9 months ago)
- Branches:
- guix
- Children:
- 8fb44c2
- Parents:
- 44c3377
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
flowtimer/RecurringPhaseSequence.py
r44c3377 r1fd7029 12 12 return Phase(d['title'], d['initial_ticks']) 13 13 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") 15 16 return d 16 17 return json.loads(a_json_string, object_hook=custom_object_hook) … … 18 19 @classmethod 19 20 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}, 21 23 {"title": "Tasking", "initial_ticks": 5}, 22 24 {"title": "Work", "initial_ticks": 45}, … … 28 30 return cls.from_json(cls.default_json_string()) 29 31 30 def __init__(self, phase_list, repetitions):32 def __init__(self, title, phase_list, repetitions): 31 33 assert repetitions > 0 32 34 assert phase_list is not [] 35 self._title = title 33 36 self.state = "initial" 34 37 self.phase_list = phase_list … … 40 43 return json.dumps(self.__dict__, default=lambda each: each.to_json()) 41 44 45 @property 42 46 def title(self): 43 return self. current_phase.title47 return self._title 44 48 45 49 def current_phase_number(self): … … 53 57 return self.phase_list[self.current_phase_number()+1:] 54 58 return [] 59 60 @property 61 def initial_ticks(self): 62 return sum([each.initial_ticks for each in self.phase_list]) 55 63 56 64 @property … … 67 75 self.current_phase.abort() 68 76 self.state = "finished" 77 78 def start(self): 79 self.state = "running" 69 80 70 81 def tick(self, ticks):
Note:
See TracChangeset
for help on using the changeset viewer.