Skip to content

Commit dafef82

Browse files
committed
Update README.md
1 parent 4415f16 commit dafef82

File tree

2 files changed

+67
-14
lines changed

2 files changed

+67
-14
lines changed

README.md

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,40 @@ Simple wait
88
[![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://pypi.org/project/black/)
99
[![License](https://img.shields.io/badge/license-MIT-black.svg)](https://opensource.org/licenses/MIT)
1010

11+
## Example
12+
```python
13+
from datetime import datetime
14+
from simple_wait import wait
15+
16+
17+
print("Start wait")
18+
wait(seconds=5)
19+
print("Finish wait")
20+
21+
while True:
22+
print()
23+
print("Current datetime:", datetime.now())
24+
print()
25+
wait(minutes=1, seconds=30)
26+
```
27+
28+
```python
29+
import traceback
30+
from simple_wait import wait
31+
32+
33+
while True:
34+
try:
35+
# Process
36+
...
37+
38+
wait(hours=8)
39+
40+
except:
41+
print(traceback.format_exc())
42+
wait(minutes=15)
43+
```
44+
1145
## Installation
1246
You can install with:
1347
```
@@ -24,18 +58,23 @@ Install or update from github:
2458
pip install git+https://github.com/gil9red/simple-wait
2559
```
2660

27-
## Example:
28-
```python
29-
from datetime import datetime
30-
from simple_wait import wait
61+
## Description
3162

32-
print("Start wait")
33-
wait(seconds=5)
34-
print("Finish wait")
63+
Parameters `wait` function:
3564

36-
while True:
37-
print()
38-
print("Current datetime:", datetime.now())
39-
print()
40-
wait(minutes=1, seconds=30)
41-
```
65+
| Name | Type | Default |
66+
|------------------------|----------------------|------------------------------------------------|
67+
| days | `int` | `0` |
68+
| seconds | `int` | `0` |
69+
| microseconds | `int` | `0` |
70+
| milliseconds | `int` | `0` |
71+
| minutes | `int` | `0` |
72+
| hours | `int` | `0` |
73+
| weeks | `int` | `0` |
74+
| progress_bar | `Iterable[str]` | `("|", "/", "-", "\\")` |
75+
| delay_seconds | `float` | `1` |
76+
| log_pattern_progress | `str` | `"[{progress_bar}] Time left to wait: {left}"` |
77+
| log_pattern_cancel | `str` | `"\nWaiting canceled\n"` |
78+
| log_pattern_clear_line | `str` | `"\r" + " " * 100 + "\r"` |
79+
| log | `TextIOWrapper` | `sys.stdout` |
80+
| is_need_stop | `Callable[[], bool]` | `lambda: False` |

src/simple_wait/__init__.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf-8 -*-
33

44
__author__ = "ipetrash"
5-
__version__ = "1.0.7"
5+
__version__ = "1.0.8"
66

77

88
import sys
@@ -15,6 +15,11 @@
1515

1616

1717
def str_timedelta(td: timedelta) -> str:
18+
"""
19+
Returns a string description of the datetime.timedelta object
20+
21+
"""
22+
1823
td = str(td)
1924

2025
# Remove ms
@@ -39,6 +44,11 @@ def get_timeout_date(
3944
hours: int = 0,
4045
weeks: int = 0,
4146
) -> datetime:
47+
"""
48+
Returns a new datetime.datetime object with the modified date
49+
50+
"""
51+
4252
if date is None:
4353
date = datetime.today()
4454

@@ -69,6 +79,10 @@ def wait(
6979
log: TextIOWrapper = sys.stdout,
7080
is_need_stop: Callable[[], bool] = lambda: False,
7181
):
82+
"""
83+
The function calls the wait for the specified period.
84+
85+
"""
7286
try:
7387
progress_bar = cycle(progress_bar)
7488

0 commit comments

Comments
 (0)