Skip to content

Commit 944ffa1

Browse files
Merge pull request #64 from sepandhaghighi/dev
Version 0.5
2 parents 407bb9d + 19902ba commit 944ffa1

File tree

12 files changed

+196
-74
lines changed

12 files changed

+196
-74
lines changed

Diff for: .github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ubuntu-latest, windows-latest, macOS-latest]
15-
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
15+
python-version: [3.5, 3.6, 3.7, 3.8, 3.9, 3.10.0]
1616
steps:
1717
- uses: actions/checkout@v2
1818
- name: Set up Python ${{ matrix.python-version }}

Diff for: AUTHORS.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Core Developers #
22

33
----------
4-
- Sepand Haghighi - Sharif University Of Technology - ([@sepandhaghighi](http://github.com/sepandhaghighi)) ([[email protected]](mailto:[email protected]))
5-
- Sadra Sabouri - Sharif University Of Technology - ([@sadrasabouri](https://github.com/sadrasabouri)) ([[email protected]](mailto:[email protected]))
4+
- Sepand Haghighi - Sharif University of Technology - ([@sepandhaghighi](http://github.com/sepandhaghighi)) ([[email protected]](mailto:[email protected]))
5+
- Sadra Sabouri - Sharif University of Technology - ([@sadrasabouri](https://github.com/sadrasabouri)) ([[email protected]](mailto:[email protected]))
66

Diff for: CHANGELOG.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
## [0.5] - 2022-05-09
9+
### Added
10+
- Decision-Making program
11+
- `time_calc` function
12+
- `time_average_calc` function
13+
### Changed
14+
- `AUTHORS.md` updated
15+
- License updated
16+
- `README.md` modified
17+
- `Python 3.10` added to `test.yml`
18+
- `time_convert` function modified
19+
- `get_input_standard` function modified
20+
- Menu updated
21+
- Relax program renamed to Relax1
22+
- 4-7-8 program renamed to Relax2
23+
- 7-11 program renamed to Relax3
824
## [0.4] - 2021-05-12
925
### Added
1026
- `start.wav`
@@ -50,7 +66,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
5066
- Anti-Appetite program
5167
- Cigarette Replace program
5268

53-
[Unreleased]: https://github.com/sepandhaghighi/nafas/compare/v0.4...dev
69+
[Unreleased]: https://github.com/sepandhaghighi/nafas/compare/v0.5...dev
70+
[0.5]: https://github.com/sepandhaghighi/nafas/compare/v0.4...v0.5
5471
[0.4]: https://github.com/sepandhaghighi/nafas/compare/v0.3...v0.4
5572
[0.3]: https://github.com/sepandhaghighi/nafas/compare/v0.2...v0.3
5673
[0.2]: https://github.com/sepandhaghighi/nafas/compare/v0.1...v0.2

Diff for: LICENSE

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ MIT License
22

33
Copyright (c) 2020 Sepand Haghighi
44

5+
Copyright (c) 2020 Sadra Sabouri
6+
57
Permission is hereby granted, free of charge, to any person obtaining a copy
68
of this software and associated documentation files (the "Software"), to deal
79
in the Software without restriction, including without limitation the rights

Diff for: README.md

+26-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
<a href="https://codecov.io/gh/sepandhaghighi/nafas">
88
<img src="https://codecov.io/gh/sepandhaghighi/nafas/branch/master/graph/badge.svg" alt="Codecov" /></a>
99
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/built%20with-Python3-green.svg" alt="built with Python3" /></a>
10-
10+
<a href="https://discord.gg/CtZUNKJHP4">
11+
<img src="https://img.shields.io/discord/901570530145107978.svg" alt="Discord Channel">
12+
</a>
1113
</div>
1214

1315
----------
@@ -39,7 +41,7 @@ No need to walk away to take a break, just sit comfortably, run Nafas and let th
3941
</tr>
4042
<tr>
4143
<td align="center">PyPI Counter</td>
42-
<td align="center"><a href="http://pepy.tech/count/nafas"><img src="http://pepy.tech/badge/nafas"></a></td>
44+
<td align="center"><a href="http://pepy.tech/project/nafas"><img src="http://pepy.tech/badge/nafas"></a></td>
4345
</tr>
4446
<tr>
4547
<td align="center">Github Stars</td>
@@ -76,19 +78,19 @@ No need to walk away to take a break, just sit comfortably, run Nafas and let th
7678
## Installation
7779

7880
### Source Code
79-
- Download [Version 0.4](https://github.com/sepandhaghighi/nafas/archive/v0.4.zip) or [Latest Source ](https://github.com/sepandhaghighi/nafas/archive/dev.zip)
81+
- Download [Version 0.5](https://github.com/sepandhaghighi/nafas/archive/v0.5.zip) or [Latest Source ](https://github.com/sepandhaghighi/nafas/archive/dev.zip)
8082
- `pip install -r requirements.txt` or `pip3 install -r requirements.txt` (Need root access)
8183
- `python3 setup.py install` or `python setup.py install` (Need root access)
8284

8385
### PyPI
8486

8587
- Check [Python Packaging User Guide](https://packaging.python.org/installing/)
86-
- `pip install nafas==0.4` or `pip3 install nafas==0.4` (Need root access)
88+
- `pip install nafas==0.5` or `pip3 install nafas==0.5` (Need root access)
8789

8890

8991
### Exe Version (Only Windows)
90-
- Download [Exe-Version 0.4](https://github.com/sepandhaghighi/nafas/releases/download/v0.4/NAFAS-0.4.exe)
91-
- Run `NAFAS-0.4.exe`
92+
- Download [Exe-Version 0.5](https://github.com/sepandhaghighi/nafas/releases/download/v0.5/NAFAS-0.5.exe)
93+
- Run `NAFAS-0.5.exe`
9294

9395

9496
## Usage
@@ -103,9 +105,15 @@ No need to walk away to take a break, just sit comfortably, run Nafas and let th
103105

104106
## Issues & Bug Reports
105107

106-
Just fill an issue and describe it. I'll check it ASAP!
107-
or send an email to [[email protected]](mailto:[email protected] "[email protected]").
108+
Just fill an issue and describe it. We'll check it ASAP!
109+
110+
- Please complete the issue template
111+
112+
You can also join our discord server
108113

114+
<a href="https://discord.gg/CtZUNKJHP4">
115+
<img src="https://img.shields.io/discord/901570530145107978.svg?style=for-the-badge" alt="Discord Channel">
116+
</a>
109117

110118
## Dependencies
111119

@@ -140,8 +148,10 @@ or send an email to [[email protected]](mailto:[email protected] "[email protected]").
140148
<blockquote>8- <a href="https://www.drweil.com/health-wellness/body-mind-spirit/stress-anxiety/breathing-three-exercises/">DrWeil, Integrative Medicine & Healthy Living</a> </blockquote>
141149

142150
<blockquote>9- <a href="https://www.hgi.org.uk/resources/delve-our-extensive-library/resources-and-techniques/7-11-breathing-how-does-deep">Human Givens Institute</a> </blockquote>
151+
152+
<blockquote>10- <a href="https://www.inc.com/mithu-storoni/this-2-minute-breathing-exercise-can-help-you-make-better-decisions-according-to-a-new-study.html">This 2-Minute Breathing Exercise Can Help You Make Better Decisions</a> </blockquote>
143153
144-
<blockquote>10- <a href="https://ttsmp3.com/">Free Text-To-Speech and Text-to-MP3 for US English</a> </blockquote>
154+
<blockquote>11- <a href="https://ttsmp3.com/">Free Text-To-Speech and Text-to-MP3 for US English</a> </blockquote>
145155

146156

147157
## Show your support
@@ -171,5 +181,10 @@ bnb1zglwcf0ac3d0s2f6ck5kgwvcru4tlctt4p5qef
171181
<h4>Dash</h4>
172182
Xd3Yn2qZJ7VE8nbKw2fS98aLxR5M6WUU3s
173183
<h4>Stellar</h4>
174-
175-
GALPOLPISRHIYHLQER2TLJRGUSZH52RYDK6C3HIU4PSMNAV65Q36EGNL
184+
GALPOLPISRHIYHLQER2TLJRGUSZH52RYDK6C3HIU4PSMNAV65Q36EGNL
185+
<h4>Zilliqa</h4>
186+
zil1knmz8zj88cf0exr2ry7nav9elehxfcgqu3c5e5
187+
<h4>Coffeete</h4>
188+
<a href="http://www.coffeete.ir/opensource">
189+
<img src="http://www.coffeete.ir/images/buttons/lemonchiffon.png" style="width:260px;" />
190+
</a>

Diff for: dev-requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
art==5.1
2-
playsound==1.2.2
1+
art==5.6
2+
playsound==1.3.0
33
codecov>=2.0.15
44
pytest>=4.3.1
55
pytest-cov>=2.6.1

Diff for: nafas/functions.py

+58-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"""nafas functions."""
33

44
import time
5-
from nafas.params import NAFAS_DESCRIPTION, NAFAS_NOTICE, STANDARD_MENU, STEP_MAP, PROGRAMS, PROGRAM_DESCRIPTION, SOUND_MAP, SOUND_ERROR_MESSAGE, STEP_TEMPLATE, CYCLE_TEMPLATE
5+
from nafas.params import NAFAS_DESCRIPTION, NAFAS_NOTICE, STANDARD_MENU, STANDARD_MENU_ORDER, STEP_MAP
6+
from nafas.params import PROGRAMS, PROGRAM_DESCRIPTION, SOUND_MAP, SOUND_ERROR_MESSAGE, STEP_TEMPLATE, CYCLE_TEMPLATE
67
import playsound
78
import threading
89
import os
@@ -21,22 +22,57 @@ def line(num=70, char="#"):
2122
print(num * char)
2223

2324

24-
def time_convert(input_time):
25+
def time_calc(program_data):
26+
"""
27+
Calculate program time.
28+
29+
:param program_data: program data
30+
:type program_data: dict
31+
:return: time as float
32+
"""
33+
result = sum(program_data["ratio"]) * program_data["unit"] * \
34+
program_data["cycle"] + program_data["pre"]
35+
return result
36+
37+
38+
def time_average_calc(program_data):
39+
"""
40+
Calculate average time of a program in all levels.
41+
42+
:param program_data: program data in all levels
43+
:type program_data: dict
44+
:return: average time as float
45+
"""
46+
result = 0
47+
level_number = len(program_data)
48+
for program in program_data.values():
49+
result += time_calc(program)
50+
return result / level_number
51+
52+
53+
def time_convert(input_time, average=False):
2554
"""
2655
Convert input time from sec to MM,SS format.
2756
2857
:param input_time: input time in sec
2958
:type input_time: float
59+
:param average: average flag
60+
:type average: bool
3061
:return: converted time as str
3162
"""
3263
sec = float(input_time)
3364
_days, sec = divmod(sec, 24 * 3600)
3465
_hours, sec = divmod(sec, 3600)
3566
minutes, sec = divmod(sec, 60)
36-
return ", ".join([
67+
result = ", ".join([
3768
"{:02.0f} minutes".format(minutes),
3869
"{:02.0f} seconds".format(sec),
3970
])
71+
if average:
72+
if sec >= 30:
73+
minutes += 1
74+
result = "{:02.0f} minutes".format(minutes).lstrip("0")
75+
return result
4076

4177

4278
def left_justify(words, width):
@@ -103,23 +139,19 @@ def program_description_print(program_name, level, program_data):
103139
:param program_name: program name
104140
:type program_name: str
105141
:param level: program level
106-
:type level: str
142+
:type level: str
107143
:param program_data: program data
108144
:type program_data: dict
109145
:return: None
110146
"""
111147
cycle = program_data["cycle"]
112148
ratio = program_data["ratio"]
113-
unit = program_data["unit"]
114-
pre = program_data["pre"]
115-
unit_time = 0
116149
sequence = []
117150
for index, item in enumerate(ratio):
118-
unit_time += item * unit
119151
if item != 0:
120152
sequence.append(STEP_MAP[index])
121153
sequence = ", ".join(sequence)
122-
total_time = (unit_time * cycle) + pre
154+
total_time = time_calc(program_data)
123155
line()
124156
print(
125157
PROGRAM_DESCRIPTION.format(
@@ -157,12 +189,26 @@ def get_input_standard(input_func=input):
157189
:return: input data as dict
158190
"""
159191
input_data = {"program": 1, "level": 1}
160-
for item in sorted(STANDARD_MENU.keys()):
192+
for item in STANDARD_MENU_ORDER:
161193
exit_flag = False
162194
sorted_list = sorted(list(STANDARD_MENU[item].keys()))
163-
print("- Please choose a {0} : ".format(item))
195+
print("- Please choose a {0} : \n".format(item))
164196
for i in sorted_list:
165-
print(str(i) + "- " + STANDARD_MENU[item][i])
197+
if item == "program":
198+
program_name = STANDARD_MENU[item][i]
199+
program_average_time = time_average_calc(
200+
PROGRAMS[program_name])
201+
print(
202+
str(i) +
203+
"- " +
204+
program_name +
205+
" (~ " +
206+
time_convert(
207+
program_average_time,
208+
True) +
209+
")")
210+
else:
211+
print(str(i) + "- " + STANDARD_MENU[item][i])
166212
while not exit_flag:
167213
try:
168214
input_data[item] = int(input_func(""))

0 commit comments

Comments
 (0)