Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Background color bug fixed
- `set_color` function modified
- `set_bg_color` function modified
- `run_timer` function modified
- Arguments moved to `handle_args` function
- `main` function moved to `functions.py`
- `--set-on` flag bug fixed
Expand Down
66 changes: 33 additions & 33 deletions mytimer/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,30 +695,33 @@ def run_timer(timer_function: Callable, params: Dict[str, dict], repeat: int, pr
:param program: program name
:param keep_on: keep-on flag
"""
timer_round = 1
while timer_round <= repeat or repeat == -1:
if program == "pomodoro":
pomodoro_timer(
timer_function,
params=params["timer"],
long_break_params=params["long_break"],
short_break_params=params["short_break"])
elif program in ["52-17", "112-26", "animedoro"]:
two_step_timer(timer_function, params1=params["timer"], params2=params["break"])
else:
timer_function(**params["timer"])
end_round_message = END_ROUND_MESSAGE.format(
round="{round}/{repeat}".format(round=timer_round, repeat=repeat))
if repeat == -1:
end_round_message = END_ROUND_MESSAGE.format(round=timer_round)
if timer_round < repeat or repeat == -1:
print_message(
message=end_round_message,
h_shift=params["timer"]["h_shift"],
confirm=True)
timer_round += 1
if keep_on:
keep_on_timer(params["timer"])
try:
timer_round = 1
while timer_round <= repeat or repeat == -1:
if program == "pomodoro":
pomodoro_timer(
timer_function,
params=params["timer"],
long_break_params=params["long_break"],
short_break_params=params["short_break"])
elif program in ["52-17", "112-26", "animedoro"]:
two_step_timer(timer_function, params1=params["timer"], params2=params["break"])
else:
timer_function(**params["timer"])
end_round_message = END_ROUND_MESSAGE.format(
round="{round}/{repeat}".format(round=timer_round, repeat=repeat))
if repeat == -1:
end_round_message = END_ROUND_MESSAGE.format(round=timer_round)
if timer_round < repeat or repeat == -1:
print_message(
message=end_round_message,
h_shift=params["timer"]["h_shift"],
confirm=True)
timer_round += 1
if keep_on:
keep_on_timer(params["timer"])
except (KeyboardInterrupt, EOFError):
print(EXIT_MESSAGE)


def main() -> None:
Expand Down Expand Up @@ -748,12 +751,9 @@ def main() -> None:
params_dict["long_break"] = load_params(args, program="pomodoro-long-break", is_break=True)
elif args.program in ["52-17", "112-26", "animedoro"]:
params_dict["break"] = load_params(args, is_break=True)
try:
run_timer(
timer_function=timer_function,
params=params_dict,
repeat=args.repeat,
program=args.program,
keep_on=args.keep_on)
except (KeyboardInterrupt, EOFError):
print(EXIT_MESSAGE)
run_timer(
timer_function=timer_function,
params=params_dict,
repeat=args.repeat,
program=args.program,
keep_on=args.keep_on)