Skip to content

Commit

Permalink
fix: update documents and setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mrunderline committed Jan 15, 2021
1 parent 24e6820 commit 025e9f2
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## Version 1.1.0
* Add `MultiProgressManager` class
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Version 1.1.0
-------------

- Add ``MultiProgressManager`` class
59 changes: 53 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ It's a lightweight and easy to use progress-bar for command-line/terminal applic
## Features

* **Simple**, **Lightweight** and **Easy** to use.
* Single progressbar mode
* Custom Bar Characters
* **iterate** function to auto handle progressbar in `for` loops
* Single progress bar mode.
* Multiple progress bar mode.
* Custom bar characters.
* **iterate** function to auto handle progress bar in `for` loops.

## Usage

### Single mode
```python
from cli_progressbar import Progress

Expand Down Expand Up @@ -59,11 +60,57 @@ progressbar.stop('stop status')
for user in progressbar.iterate(users, lambda user: 'processing ' + user):
# Do your stuff
```
### Multiple mode
```python
from cli_progressbar import Progress, MultiProgressManager

# define multi progress instance
manager = MultiProgressManager()

# now define any progress bar you need
progress_1 = Progress()
progress_2 = Progress()

# now add them to multi progress manager
manager.append(progress_1)
manager.append(progress_2)

# Done! It's ready to use like a single progress!
progress_1.start('start progress 1')
progress_2.start('start progress 2')
for i in progress_1.iterate(range(8), 'state progress 1'):
for j in progress_2.iterate(range(5), 'state progress 2'):
# Do your stuff

progress_1.stop('stop progress 1')
progress_2.stop('stop progress 2')
```

But maybe you want it more simple, so I have an easier solution!
```python
from cli_progressbar import MultiProgressManager

# define multi progress instance; but this time, pass 2 arguments
manager = MultiProgressManager(
progress_count=2, # default: 0
progress_prefix='progress_' # default: progress_
)

# now you can access 2 progressbar, just request them from manager
manager.progress_1.start('start progress 1')
manager.progress_2.start('start progress 2')
for i in manager.progress_1.iterate(range(8), 'state progress 1'):
for j in manager.progress_2.iterate(range(5), 'state progress 2'):
# Do your stuff

manager.progress_1.stop('stop progress 1')
manager.progress_2.stop('stop progress 2')
```

## Parameters

* `goal` to change goal in between of process, it's useful for dynamic tasks
* `bar_len` length of progressbar (default: 60)
* `bar_len` length of progress bar (default: 60)
* `fill` bar fill symbol (default: █)
* `zfill` bar zero fill symbol (default: -)
* `decimals` positive number of decimals in percent complete (default: 1)
Expand All @@ -74,4 +121,4 @@ Please open a new issue on [GitHub](https://github.com/mrunderline/cli-progressb

## License

CLI-Progress is OpenSource and licensed under the terms of [The MIT License (X11)](http://opensource.org/licenses/MIT). You're welcome to [contribute](https://github.com/mrunderline/cli-progressbar/blob/master/CONTRIBUTE.md)!
CLI-ProgressBar is OpenSource and licensed under the terms of [The MIT License (X11)](http://opensource.org/licenses/MIT). You're welcome to [contribute](https://github.com/mrunderline/cli-progressbar/blob/master/CONTRIBUTE.md)!
64 changes: 59 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ Features
--------

- **Simple**, **Lightweight** and **Easy** to use.
- Single progressbar mode
- Custom Bar Characters
- **iterate** function to auto handle progressbar in ``for`` loops
- Single progress bar mode.
- Multiple progress bar mode.
- Custom bar characters.
- **iterate** function to auto handle progress bar in ``for`` loops.

Usage
-----

Single mode
~~~~~~~~~~~

.. code:: python
from cli_progressbar import Progress
Expand Down Expand Up @@ -68,12 +72,62 @@ and each element of list as it input.
for user in progressbar.iterate(users, lambda user: 'processing ' + user):
# Do your stuff
Multiple mode
~~~~~~~~~~~~~

.. code:: python
from cli_progressbar import Progress, MultiProgressManager
# define multi progress instance
manager = MultiProgressManager()
# now define any progress bar you need
progress_1 = Progress()
progress_2 = Progress()
# now add them to multi progress manager
manager.append(progress_1)
manager.append(progress_2)
# Done! It's ready to use like a single progress!
progress_1.start('start progress 1')
progress_2.start('start progress 2')
for i in progress_1.iterate(range(8), 'state progress 1'):
for j in progress_2.iterate(range(5), 'state progress 2'):
# Do your stuff
progress_1.stop('stop progress 1')
progress_2.stop('stop progress 2')
But maybe you want it more simple, so I have an easier solution!

.. code:: python
from cli_progressbar import MultiProgressManager
# define multi progress instance; but this time, pass 2 arguments
manager = MultiProgressManager(
progress_count=2, # default: 0
progress_prefix='progress_' # default: progress_
)
# now you can access 2 progressbar, just request them from manager
manager.progress_1.start('start progress 1')
manager.progress_2.start('start progress 2')
for i in manager.progress_1.iterate(range(8), 'state progress 1'):
for j in manager.progress_2.iterate(range(5), 'state progress 2'):
# Do your stuff
manager.progress_1.stop('stop progress 1')
manager.progress_2.stop('stop progress 2')
Parameters
----------

- ``goal`` to change goal in between of process, it’s useful for
dynamic tasks
- ``bar_len`` length of progressbar (default: 60)
- ``bar_len`` length of progress bar (default: 60)
- ``fill`` bar fill symbol (default: █)
- ``zfill`` bar zero fill symbol (default: -)
- ``decimals`` positive number of decimals in percent complete
Expand All @@ -88,6 +142,6 @@ Please open a new issue on
License
-------

CLI-Progress is OpenSource and licensed under the terms of `The MIT
CLI-ProgressBar is OpenSource and licensed under the terms of `The MIT
License (X11) <http://opensource.org/licenses/MIT>`__. You’re welcome to
`contribute <https://github.com/mrunderline/cli-progressbar/blob/master/CONTRIBUTE.md>`__!
7 changes: 7 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
from importlib import import_module


def get_long_description():
readme = open("README.rst").read()
changelog = open("CHANGES.rst").read()
return "\n\n".join([readme, changelog.replace(":func:", "").replace(":ref:", "")])


setup(
name='cli_progressbar',
packages=['cli_progressbar'],
version=import_module('cli_progressbar').__version__,
license='MIT',
description='lightweight library to print progress bar in cli',
long_description=get_long_description(),
author='Ali Madihi (mrunderline)',
author_email='[email protected]',
url='https://github.com/mrunderline/cli-progressbar',
Expand Down

0 comments on commit 025e9f2

Please sign in to comment.