|
| 1 | +# Enter task name |
| 2 | +# Set the timer (default 25 minutes) |
| 3 | +# Give updates every minute |
| 4 | +# Timer rings, print ASCII |
| 5 | +# Check if task is done |
| 6 | +# If task is done, add task to done list |
| 7 | +# If total tasks % 4 isn't 0, short break (3-5 minutes), start at the top |
| 8 | +# If tasks % 4 == 0, take a break (15-30 minutes) |
| 9 | +# Setup logging to write out completed tasks and timestamp - other stats? |
| 10 | +# Setup a way to leave the timer |
| 11 | +# Dialog to start, stop or exit |
| 12 | + |
| 13 | +import time |
| 14 | + |
| 15 | +from datetime import datetime, timedelta |
| 16 | + |
| 17 | + |
| 18 | +def choose_tasks(tasks_todo=[]): |
| 19 | + """ Manages items from the task list |
| 20 | + Args: |
| 21 | + tasks_todo - list, contains items to complete |
| 22 | + """ |
| 23 | + print() |
| 24 | + print("What task do you want to complete?\n") |
| 25 | + for num, task in enumerate(tasks_todo, 1): |
| 26 | + print(f"{num}. {task}\n") |
| 27 | + task_choice = input("Choose from the list or enter a new task: ") |
| 28 | + return(task_choice) |
| 29 | + |
| 30 | + |
| 31 | +def set_current_task(task_choice, tasks_todo): |
| 32 | + if not task_choice.isdigit(): |
| 33 | + tasks_todo.append(task_choice) |
| 34 | + current_task = task_choice |
| 35 | + else: |
| 36 | + current_task = tasks_todo[int(task_choice)-1] |
| 37 | + return current_task |
| 38 | + |
| 39 | + |
| 40 | +def get_parameters(): |
| 41 | + """ TODO - Could also add something to check if int""" |
| 42 | + focus = None |
| 43 | + short_break = None |
| 44 | + long_break = None |
| 45 | + |
| 46 | + while True: |
| 47 | + focus = input("How long do you want the working " |
| 48 | + "sessions to be? (20-30 minutes): ") |
| 49 | + if 20 <= int(focus) <= 30: |
| 50 | + break |
| 51 | + else: |
| 52 | + print("Please enter a number between 20 and 30") |
| 53 | + |
| 54 | + while True: |
| 55 | + short_break = input("How long do you want the short " |
| 56 | + "breaks to be? (2-5 minutes): ") |
| 57 | + if 2 <= int(short_break) <= 5: |
| 58 | + break |
| 59 | + else: |
| 60 | + print("Please enter a number between 2 and 5") |
| 61 | + |
| 62 | + while True: |
| 63 | + long_break = input("How long do you want the long " |
| 64 | + "break to be? (15-30 minutes): ") |
| 65 | + if 15 <= int(long_break) <= 30: |
| 66 | + break |
| 67 | + else: |
| 68 | + print("Please enter a number between 15 and 30") |
| 69 | + |
| 70 | + return {"focus": int(focus), "short_break": int(short_break), "long_break": int(long_break)} |
| 71 | + |
| 72 | + |
| 73 | +def setup_pomodoro(current_task, focus=25, short_break=3, long_break=20): |
| 74 | + """ Sets up the basic rules of the pomodor. |
| 75 | + Args: |
| 76 | + current_task: str - thing we're doing |
| 77 | + focus: int - total working length |
| 78 | + short_break: int - short break length |
| 79 | + long_break: int - break after 4 pomodoros |
| 80 | + """ |
| 81 | + pomodoros = 0 |
| 82 | + |
| 83 | + while True: |
| 84 | + # start focus timer |
| 85 | + work() |
| 86 | + manage_timer(focus, "working") |
| 87 | + pomodoros += 1 |
| 88 | + if pomodoros % 4: |
| 89 | + take_break() |
| 90 | + manage_timer(long_break, "on a long break") |
| 91 | + else: |
| 92 | + take_break() |
| 93 | + manage_timer(short_break, "on a short break") |
| 94 | + |
| 95 | + |
| 96 | +def manage_timer(timer, timer_type): |
| 97 | + """TODO: |
| 98 | + Use keyboard interrupt to pause |
| 99 | + Give minute by minute time updates |
| 100 | + Print what the instructions are |
| 101 | + """ |
| 102 | + print(f"You're currently {timer_type}.\nYou have {timer} minutes remaining") |
| 103 | + try: |
| 104 | + t = timedelta(minutes=timer).seconds |
| 105 | + time.sleep(t) |
| 106 | + except KeyboardInterrupt: |
| 107 | + print("Jigga what?") |
| 108 | + |
| 109 | + |
| 110 | +def convert_time(interval): |
| 111 | + """Converts user input into datetime objects""" |
| 112 | + converted_time = datetime.strptime(str(interval), "%M") |
| 113 | + return converted_time.seconds |
| 114 | + |
| 115 | + |
| 116 | +def start_now_pomo(): |
| 117 | + """TODO Deal with completed tasks and reset pomo""" |
| 118 | + |
| 119 | + |
| 120 | +def take_break(): |
| 121 | + """ASCII Amazingness for break time - crawford2""" |
| 122 | + print(r""" |
| 123 | + ______ ____ __ _ ___ ____ ____ ____ ___ ____ __ _ __ |
| 124 | + | | / || |/ ] / _] / | | \ | \ / _] / || |/ ]| | |
| 125 | + | || o || ' / / [_ | o | | o )| D ) / [_ | o || ' / | | |
| 126 | + |_| |_|| || \ | _] | | | || / | _]| || \ |__| |
| 127 | + | | | _ || \| [_ | _ | | O || \ | [_ | _ || \ __ |
| 128 | + | | | | || . || | | | | | || . \| || | || . || | |
| 129 | + |__| |__|__||__|\_||_____| |__|__| |_____||__|\_||_____||__|__||__|\_||__| |
| 130 | + """) |
| 131 | + |
| 132 | + |
| 133 | +def work(): |
| 134 | + """ASCII Amazingness for break time - crawford2""" |
| 135 | + print(r""" |
| 136 | + __ __ ___ ____ __ _ |
| 137 | + | |__| | / \ | \ | |/ ] |
| 138 | + | | | || || D )| ' / |
| 139 | + | | | || O || / | \ |
| 140 | + | ` ' || || \ | \ |
| 141 | + \ / | || . \| . | |
| 142 | + \_/\_/ \___/ |__|\_||__|\_| |
| 143 | + """) |
| 144 | + |
| 145 | + |
| 146 | +def complete_tasks(tasks_todo, tasks_complete, current_task): |
| 147 | + tasks_todo.remove(current_task) |
| 148 | + tasks_complete.append(current_task) |
| 149 | + |
| 150 | + |
| 151 | +def first_time(): |
| 152 | + tasks_todo = [] |
| 153 | + tasks_complete = [] |
| 154 | + |
| 155 | + task_choice = choose_tasks() |
| 156 | + print() |
| 157 | + current_task = set_current_task(task_choice, tasks_todo) |
| 158 | + params = get_parameters() |
| 159 | + setup_pomodoro(current_task, **params) |
| 160 | + |
| 161 | + |
| 162 | +first_time() |
0 commit comments