Skip to content

Commit

Permalink
Merge pull request #64 from sepandhaghighi/dev
Browse files Browse the repository at this point in the history
Version 0.5
  • Loading branch information
sepandhaghighi authored May 9, 2022
2 parents 407bb9d + 19902ba commit 944ffa1
Show file tree
Hide file tree
Showing 12 changed files with 196 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
python-version: [3.5, 3.6, 3.7, 3.8, 3.9, 3.10.0]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
4 changes: 2 additions & 2 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Core Developers #

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

19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.5] - 2022-05-09
### Added
- Decision-Making program
- `time_calc` function
- `time_average_calc` function
### Changed
- `AUTHORS.md` updated
- License updated
- `README.md` modified
- `Python 3.10` added to `test.yml`
- `time_convert` function modified
- `get_input_standard` function modified
- Menu updated
- Relax program renamed to Relax1
- 4-7-8 program renamed to Relax2
- 7-11 program renamed to Relax3
## [0.4] - 2021-05-12
### Added
- `start.wav`
Expand Down Expand Up @@ -50,7 +66,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Anti-Appetite program
- Cigarette Replace program

[Unreleased]: https://github.com/sepandhaghighi/nafas/compare/v0.4...dev
[Unreleased]: https://github.com/sepandhaghighi/nafas/compare/v0.5...dev
[0.5]: https://github.com/sepandhaghighi/nafas/compare/v0.4...v0.5
[0.4]: https://github.com/sepandhaghighi/nafas/compare/v0.3...v0.4
[0.3]: https://github.com/sepandhaghighi/nafas/compare/v0.2...v0.3
[0.2]: https://github.com/sepandhaghighi/nafas/compare/v0.1...v0.2
Expand Down
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ MIT License

Copyright (c) 2020 Sepand Haghighi

Copyright (c) 2020 Sadra Sabouri

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
Expand Down
37 changes: 26 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
<a href="https://codecov.io/gh/sepandhaghighi/nafas">
<img src="https://codecov.io/gh/sepandhaghighi/nafas/branch/master/graph/badge.svg" alt="Codecov" /></a>
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/built%20with-Python3-green.svg" alt="built with Python3" /></a>

<a href="https://discord.gg/CtZUNKJHP4">
<img src="https://img.shields.io/discord/901570530145107978.svg" alt="Discord Channel">
</a>
</div>

----------
Expand Down Expand Up @@ -39,7 +41,7 @@ No need to walk away to take a break, just sit comfortably, run Nafas and let th
</tr>
<tr>
<td align="center">PyPI Counter</td>
<td align="center"><a href="http://pepy.tech/count/nafas"><img src="http://pepy.tech/badge/nafas"></a></td>
<td align="center"><a href="http://pepy.tech/project/nafas"><img src="http://pepy.tech/badge/nafas"></a></td>
</tr>
<tr>
<td align="center">Github Stars</td>
Expand Down Expand Up @@ -76,19 +78,19 @@ No need to walk away to take a break, just sit comfortably, run Nafas and let th
## Installation

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

### PyPI

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


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


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

## Issues & Bug Reports

Just fill an issue and describe it. I'll check it ASAP!
or send an email to [[email protected]](mailto:[email protected] "[email protected]").
Just fill an issue and describe it. We'll check it ASAP!

- Please complete the issue template

You can also join our discord server

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

## Dependencies

Expand Down Expand Up @@ -140,8 +148,10 @@ or send an email to [[email protected]](mailto:[email protected] "[email protected]").
<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>

<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>

<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>
<blockquote>10- <a href="https://ttsmp3.com/">Free Text-To-Speech and Text-to-MP3 for US English</a> </blockquote>
<blockquote>11- <a href="https://ttsmp3.com/">Free Text-To-Speech and Text-to-MP3 for US English</a> </blockquote>


## Show your support
Expand Down Expand Up @@ -171,5 +181,10 @@ bnb1zglwcf0ac3d0s2f6ck5kgwvcru4tlctt4p5qef
<h4>Dash</h4>
Xd3Yn2qZJ7VE8nbKw2fS98aLxR5M6WUU3s
<h4>Stellar</h4>

GALPOLPISRHIYHLQER2TLJRGUSZH52RYDK6C3HIU4PSMNAV65Q36EGNL
GALPOLPISRHIYHLQER2TLJRGUSZH52RYDK6C3HIU4PSMNAV65Q36EGNL
<h4>Zilliqa</h4>
zil1knmz8zj88cf0exr2ry7nav9elehxfcgqu3c5e5
<h4>Coffeete</h4>
<a href="http://www.coffeete.ir/opensource">
<img src="http://www.coffeete.ir/images/buttons/lemonchiffon.png" style="width:260px;" />
</a>
4 changes: 2 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
art==5.1
playsound==1.2.2
art==5.6
playsound==1.3.0
codecov>=2.0.15
pytest>=4.3.1
pytest-cov>=2.6.1
Expand Down
70 changes: 58 additions & 12 deletions nafas/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"""nafas functions."""

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


def time_convert(input_time):
def time_calc(program_data):
"""
Calculate program time.
:param program_data: program data
:type program_data: dict
:return: time as float
"""
result = sum(program_data["ratio"]) * program_data["unit"] * \
program_data["cycle"] + program_data["pre"]
return result


def time_average_calc(program_data):
"""
Calculate average time of a program in all levels.
:param program_data: program data in all levels
:type program_data: dict
:return: average time as float
"""
result = 0
level_number = len(program_data)
for program in program_data.values():
result += time_calc(program)
return result / level_number


def time_convert(input_time, average=False):
"""
Convert input time from sec to MM,SS format.
:param input_time: input time in sec
:type input_time: float
:param average: average flag
:type average: bool
:return: converted time as str
"""
sec = float(input_time)
_days, sec = divmod(sec, 24 * 3600)
_hours, sec = divmod(sec, 3600)
minutes, sec = divmod(sec, 60)
return ", ".join([
result = ", ".join([
"{:02.0f} minutes".format(minutes),
"{:02.0f} seconds".format(sec),
])
if average:
if sec >= 30:
minutes += 1
result = "{:02.0f} minutes".format(minutes).lstrip("0")
return result


def left_justify(words, width):
Expand Down Expand Up @@ -103,23 +139,19 @@ def program_description_print(program_name, level, program_data):
:param program_name: program name
:type program_name: str
:param level: program level
:type level: str
:type level: str
:param program_data: program data
:type program_data: dict
:return: None
"""
cycle = program_data["cycle"]
ratio = program_data["ratio"]
unit = program_data["unit"]
pre = program_data["pre"]
unit_time = 0
sequence = []
for index, item in enumerate(ratio):
unit_time += item * unit
if item != 0:
sequence.append(STEP_MAP[index])
sequence = ", ".join(sequence)
total_time = (unit_time * cycle) + pre
total_time = time_calc(program_data)
line()
print(
PROGRAM_DESCRIPTION.format(
Expand Down Expand Up @@ -157,12 +189,26 @@ def get_input_standard(input_func=input):
:return: input data as dict
"""
input_data = {"program": 1, "level": 1}
for item in sorted(STANDARD_MENU.keys()):
for item in STANDARD_MENU_ORDER:
exit_flag = False
sorted_list = sorted(list(STANDARD_MENU[item].keys()))
print("- Please choose a {0} : ".format(item))
print("- Please choose a {0} : \n".format(item))
for i in sorted_list:
print(str(i) + "- " + STANDARD_MENU[item][i])
if item == "program":
program_name = STANDARD_MENU[item][i]
program_average_time = time_average_calc(
PROGRAMS[program_name])
print(
str(i) +
"- " +
program_name +
" (~ " +
time_convert(
program_average_time,
True) +
")")
else:
print(str(i) + "- " + STANDARD_MENU[item][i])
while not exit_flag:
try:
input_data[item] = int(input_func(""))
Expand Down
Loading

0 comments on commit 944ffa1

Please sign in to comment.