py-bar/README.md

122 lines
4.6 KiB
Markdown
Raw Permalink Normal View History

2023-12-15 17:26:51 -05:00
<!-- Header -->
<div id="top" align="center">
<br />
2016-05-10 21:16:56 -04:00
2023-12-15 17:26:51 -05:00
<!-- Logo -->
<img src="https://git.zakscode.com/repo-avatars/002f97340c2781ccfa5d09fde97403fd499c39a9ad5675dc0edf05a8396e9ac5" alt="Logo" width="200" height="200">
2016-05-10 21:22:12 -04:00
2023-12-15 17:26:51 -05:00
<!-- Title -->
### py-bar
2016-05-10 21:22:12 -04:00
2023-12-15 17:26:51 -05:00
<!-- Description -->
Python ASCII Progress Bar
2016-05-10 21:22:12 -04:00
2023-12-15 17:26:51 -05:00
<!-- Repo badges -->
[![Version](https://img.shields.io/badge/dynamic/json.svg?label=Version&style=for-the-badge&url=https://git.zakscode.com/api/v1/repos/ztimson/py-bar/tags&query=$[0].name)](https://git.zakscode.com/ztimson/py-bar/tags)
[![Pull Requests](https://img.shields.io/badge/dynamic/json.svg?label=Pull%20Requests&style=for-the-badge&url=https://git.zakscode.com/api/v1/repos/ztimson/py-bar&query=open_pr_counter)](https://git.zakscode.com/ztimson/py-bar/pulls)
[![Issues](https://img.shields.io/badge/dynamic/json.svg?label=Issues&style=for-the-badge&url=https://git.zakscode.com/api/v1/repos/ztimson/py-bar&query=open_issues_count)](https://git.zakscode.com/ztimson/py-bar/issues)
2016-05-10 21:22:12 -04:00
2023-12-15 17:26:51 -05:00
<!-- Links -->
2016-05-10 21:22:12 -04:00
2023-12-15 17:26:51 -05:00
---
<div>
<a href="https://git.zakscode.com/ztimson/py-bar/releases" target="_blank">Release Notes</a>
<a href="https://git.zakscode.com/ztimson/py-bar/issues/new?template=.github%2fissue_template%2fbug.md" target="_blank">Report a Bug</a>
<a href="https://git.zakscode.com/ztimson/py-bar/issues/new?template=.github%2fissue_template%2fenhancement.md" target="_blank">Request a Feature</a>
</div>
2016-05-10 21:22:12 -04:00
2023-12-15 17:26:51 -05:00
---
</div>
2016-05-10 21:22:12 -04:00
2023-12-15 17:26:51 -05:00
## Table of Contents
- [py-bar](#top)
- [About](#about)
- [Built With](#built-with)
- [Setup](#setup)
- [Production](#production)
- [Documentation](#documentation)
- [License](#license)
2016-05-10 21:22:12 -04:00
2023-12-15 17:26:51 -05:00
## About
2016-05-10 21:22:12 -04:00
2023-12-15 17:26:51 -05:00
Python CLI Progress bar. This module is an iterator that can not only, iterate, but display its self as a progressbar along with some other usefull iformation such as iterations a second, estimated time, elapsed time, etc.
2016-05-10 21:22:12 -04:00
2023-12-15 17:26:51 -05:00
`00:25 100% [====================] [100/100] 3.99/s 00:00`
2016-05-10 21:22:12 -04:00
2023-12-15 17:26:51 -05:00
### Built With
[![Python](https://img.shields.io/badge/Python-FFD43B?style=for-the-badge&logo=python)](https://www.python.org/)
2016-05-10 21:16:56 -04:00
2023-12-15 17:26:51 -05:00
## Setup
2017-07-31 17:50:49 -04:00
2023-12-15 17:26:51 -05:00
<details>
<summary>
<h3 id="production" style="display: inline">
Production
</h3>
</summary>
2016-05-10 21:22:12 -04:00
2023-12-15 17:26:51 -05:00
#### Prerequisites
- [Python](https://www.python.org/downloads/)
2016-05-10 21:22:12 -04:00
2023-12-15 17:26:51 -05:00
#### Instructions
1. Download and add script to project: `curl https://git.zakscode.com/ztimson/py-bar/raw/branch/develop/progressbar.py`
2. Use in python script:
2016-05-10 21:22:12 -04:00
2023-12-15 17:26:51 -05:00
```python
from progressbar import Progressbar
2016-05-10 21:22:12 -04:00
2023-12-15 17:26:51 -05:00
for i in Progressbar(100):
...
2016-05-10 21:22:12 -04:00
2023-12-15 17:26:51 -05:00
# OR
2016-02-09 15:22:56 -05:00
2023-12-15 17:26:51 -05:00
progress = Progressbar(100, display=False) # Output manually
for i in progress:
print(str(progress)) # Print progress bar
...
```
2017-07-31 17:50:49 -04:00
2023-12-15 17:26:51 -05:00
</details>
## Documentation
### Progressbar
#### Constructor Arguments
| Name | Description |
|------------|---------------------------------------------|
| start | Iterator starting position |
| end | Iterator ending position |
| current | Current iteration position |
| step | Added to current index after each iteration |
| length | ASCII progress bar string length |
| units | Unit to append to progress rate |
| color | ANSI escape code to color progress bar |
| display | Automatically output to sdtout |
| bar_format | Custom progress bar format string |
#### Properties
| Name | Description |
|------------|----------------------------------------------------|
| elapsed | Time ellapsed since first iteration: mm:ss |
| percentage | Percentage of completion: 50% |
| bar | ASCII progress bar: \|==========\| |
| fraction | Position as a fraction: \[index/total\] |
| rate | Iterations per second: 2.00/s |
| eta | Estimated time until complete: mm:ss |
#### Methods
| Name | Description |
|----------------------|----------------------------------------------|
| elapsed(self) | Elapsed time in seconds |
| estimated_time(self) | Estimated time until completion in seconds |
| fraction(self) | Create fraction string |
| generate_bar | Progress bar ASCII string |
| per_second | Calculate iteration rate per second as float |
| percentage | Percentage as a floating point |
## License
Copyright © 2023 Zakary Timson | Available under the GNU General Public License
See the [license](./LICENSE) for more information.