Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor edits #105

Merged
merged 5 commits into from
Oct 22, 2024
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
4 changes: 4 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@

# Other Contributors
----------
- [@sarahfard](https://github.com/sarahfard) **
- [@oscarArismendi](https://github.com/oscarArismendi)


** Graphic designer

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed
- Restart mode updated
- Exit bug fixed
- Messages and templates moved to `params.py`
## [0.7] - 2024-08-27
### Added
- `feature_request.yml` template
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ You can also join our discord server

<blockquote>13- <a href="https://www.yogabasics.com/practice/pranayama/">Pranayama Breathing Techniques and Tips</a> </blockquote>

* Logo designed by [Sara Amiri Fard](https://github.com/sarahfard)

## Show Your Support

Expand Down
20 changes: 11 additions & 9 deletions nafas/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import time
from nafas.params import NAFAS_DESCRIPTION, NAFAS_NOTICE, STANDARD_MENU, STANDARD_MENU_ORDER, STEP_MAP
from nafas.params import PROGRAMS, PROGRAM_DESCRIPTION, SOUND_MAP, STEP_TEMPLATE, CYCLE_TEMPLATE
from nafas.params import SOUND_WARNING_MESSAGE, EXIT_MESSAGE
from nafas.params import SOUND_WARNING_MESSAGE, EXIT_MESSAGE, BAD_INPUT_MESSAGE, PROGRAM_END_MESSAGE
from nafas.params import MINUTES_TEMPLATE, SECONDS_TEMPLATE, PROGRAM_TIME_TEMPLATE
from nafas.params import MENU_TEMPLATE_1, MENU_TEMPLATE_2
import nava
import os
from warnings import warn
Expand Down Expand Up @@ -67,13 +69,13 @@ def time_convert(input_time, average=False):
_hours, sec = divmod(sec, 3600)
minutes, sec = divmod(sec, 60)
result = ", ".join([
"{:02.0f} minutes".format(minutes),
"{:02.0f} seconds".format(sec),
MINUTES_TEMPLATE.format(minutes),
SECONDS_TEMPLATE.format(sec),
])
if average:
if sec >= 30:
minutes += 1
result = "{:02.0f} minutes".format(minutes).lstrip("0")
result = MINUTES_TEMPLATE.format(minutes).lstrip("0")
return result


Expand Down Expand Up @@ -209,14 +211,14 @@ def get_input_standard(input_func=input):
for item in STANDARD_MENU_ORDER:
exit_flag = False
sorted_list = sorted(STANDARD_MENU[item])
print("- Please choose a {0} : \n".format(item))
print(MENU_TEMPLATE_1.format(item))
for i in sorted_list:
if item == "program":
program_name = STANDARD_MENU[item][i]
program_average_time = time_average_calc(PROGRAMS[program_name])
print("{0}- {1} (~ {2})".format(i, program_name, time_convert(program_average_time, True)))
print(PROGRAM_TIME_TEMPLATE.format(i, program_name, time_convert(program_average_time, True)))
else:
print("{0}- {1}".format(i, STANDARD_MENU[item][i]))
print(MENU_TEMPLATE_2.format(i, STANDARD_MENU[item][i]))
while not exit_flag:
try:
input_data[item] = int(input_func(""))
Expand All @@ -225,7 +227,7 @@ def get_input_standard(input_func=input):
print("\n" + EXIT_MESSAGE)
sys.exit()
except Exception:
print("[Error] Bad Input!")
print(BAD_INPUT_MESSAGE)
return input_data


Expand Down Expand Up @@ -328,7 +330,7 @@ def run(program_data, silent=False):
time.sleep(1)
line()
play_sound(get_sound_path(SOUND_MAP['End']), enable=sound_check_flag)
print("Well done!", flush=True)
print(PROGRAM_END_MESSAGE, flush=True)
time.sleep(2)


Expand Down
14 changes: 14 additions & 0 deletions nafas/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

EXIT_MESSAGE = "See you. Bye!"

BAD_INPUT_MESSAGE = "[Error] Bad input!"

PROGRAM_END_MESSAGE = "Well done!"

PROGRAM_DESCRIPTION = """Program Details :

Name : {0}
Expand All @@ -35,6 +39,16 @@
Sequence : {4}
"""

MINUTES_TEMPLATE = "{:02.0f} minutes"

SECONDS_TEMPLATE = "{:02.0f} seconds"

PROGRAM_TIME_TEMPLATE = "{0}- {1} (~ {2})"

MENU_TEMPLATE_1 = "- Please choose a {0} : \n"

MENU_TEMPLATE_2 = "{0}- {1}"

CYCLE_TEMPLATE = "Cycle : {0} (Remaining : {1})"

STEP_TEMPLATE = "- {0} for {1} sec"
Expand Down
Loading