From 62560ad8db6bbdb90fe2adb0234a5fd5e2c9a9ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Sun, 5 Jul 2020 19:22:29 -0400 Subject: [PATCH] Put everything in a loop and try continue to not ever end up in the else? --- pomodoroprompt.py | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/pomodoroprompt.py b/pomodoroprompt.py index e4e957b..eaf039a 100644 --- a/pomodoroprompt.py +++ b/pomodoroprompt.py @@ -33,28 +33,31 @@ def record_task(whatdid, start, end=None): def main(): - whatnext = pomodoro_prompt_plan() + whatdid = '' + while True: + whatnext = pomodoro_prompt_plan(whatdid) - start = datetime.now(pytz.utc) - end = start + timedelta(minutes=WORK_MIN, seconds=0) - try: - print('Task -', whatnext) - while datetime.now(pytz.utc) <= end: - to_go = end-datetime.now(pytz.utc) - print('\r', str(to_go).split('.')[0], sep='', end='') - time.sleep(1) - whatdid = pomodoro_prompt_report(whatnext) - record_task(whatdid, start) - except KeyboardInterrupt: - print('\n{} time spent, save?'.format(str(diff).split('.')[0])) - choice = input('[y]/n: ').strip() - if choice.lower() in ('y', 'yes', ''): + start = datetime.now(pytz.utc) + end = start + timedelta(minutes=WORK_MIN, seconds=0) + try: + print('Task -', whatnext) + while datetime.now(pytz.utc) <= end: + to_go = end-datetime.now(pytz.utc) + print('\r', str(to_go).split('.')[0], sep='', end='') + time.sleep(1) whatdid = pomodoro_prompt_report(whatnext) record_task(whatdid, start) - else: - print('What did you break?') - # If we somehow end up here, try a last-ditch effort to save. - record_task('Incomplete, interrupted task:' + whatnext, start) + continue + except KeyboardInterrupt: + print('\n{} time spent, save?'.format(str(diff).split('.')[0])) + choice = input('[y]/n: ').strip() + if choice.lower() in ('y', 'yes', ''): + whatdid = pomodoro_prompt_report(whatnext) + record_task(whatdid, start) + else: + print('What did you break?') + # If we somehow end up here, try a last-ditch effort to save. + record_task('Incomplete, interrupted task:' + whatnext, start) # timelog.touch(exist_ok=True)