Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
gil9red committed May 25, 2023
1 parent 4415f16 commit dafef82
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 14 deletions.
65 changes: 52 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,40 @@ Simple wait
[![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://pypi.org/project/black/)
[![License](https://img.shields.io/badge/license-MIT-black.svg)](https://opensource.org/licenses/MIT)

## Example
```python
from datetime import datetime
from simple_wait import wait


print("Start wait")
wait(seconds=5)
print("Finish wait")

while True:
print()
print("Current datetime:", datetime.now())
print()
wait(minutes=1, seconds=30)
```

```python
import traceback
from simple_wait import wait


while True:
try:
# Process
...

wait(hours=8)

except:
print(traceback.format_exc())
wait(minutes=15)
```

## Installation
You can install with:
```
Expand All @@ -24,18 +58,23 @@ Install or update from github:
pip install git+https://github.com/gil9red/simple-wait
```

## Example:
```python
from datetime import datetime
from simple_wait import wait
## Description

print("Start wait")
wait(seconds=5)
print("Finish wait")
Parameters `wait` function:

while True:
print()
print("Current datetime:", datetime.now())
print()
wait(minutes=1, seconds=30)
```
| Name | Type | Default |
|------------------------|----------------------|------------------------------------------------|
| days | `int` | `0` |
| seconds | `int` | `0` |
| microseconds | `int` | `0` |
| milliseconds | `int` | `0` |
| minutes | `int` | `0` |
| hours | `int` | `0` |
| weeks | `int` | `0` |
| progress_bar | `Iterable[str]` | `("|", "/", "-", "\\")` |
| delay_seconds | `float` | `1` |
| log_pattern_progress | `str` | `"[{progress_bar}] Time left to wait: {left}"` |
| log_pattern_cancel | `str` | `"\nWaiting canceled\n"` |
| log_pattern_clear_line | `str` | `"\r" + " " * 100 + "\r"` |
| log | `TextIOWrapper` | `sys.stdout` |
| is_need_stop | `Callable[[], bool]` | `lambda: False` |
16 changes: 15 additions & 1 deletion src/simple_wait/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

__author__ = "ipetrash"
__version__ = "1.0.7"
__version__ = "1.0.8"


import sys
Expand All @@ -15,6 +15,11 @@


def str_timedelta(td: timedelta) -> str:
"""
Returns a string description of the datetime.timedelta object
"""

td = str(td)

# Remove ms
Expand All @@ -39,6 +44,11 @@ def get_timeout_date(
hours: int = 0,
weeks: int = 0,
) -> datetime:
"""
Returns a new datetime.datetime object with the modified date
"""

if date is None:
date = datetime.today()

Expand Down Expand Up @@ -69,6 +79,10 @@ def wait(
log: TextIOWrapper = sys.stdout,
is_need_stop: Callable[[], bool] = lambda: False,
):
"""
The function calls the wait for the specified period.
"""
try:
progress_bar = cycle(progress_bar)

Expand Down

0 comments on commit dafef82

Please sign in to comment.