From 025e9f2dfaacf075edc705ad7449ad45279bf429 Mon Sep 17 00:00:00 2001 From: ali madihi Date: Fri, 15 Jan 2021 23:42:19 +0330 Subject: [PATCH] fix: update documents and setup.py --- CHANGES.md | 2 ++ CHANGES.rst | 4 ++++ README.md | 59 +++++++++++++++++++++++++++++++++++++++++++----- README.rst | 64 ++++++++++++++++++++++++++++++++++++++++++++++++----- setup.py | 7 ++++++ 5 files changed, 125 insertions(+), 11 deletions(-) create mode 100644 CHANGES.md create mode 100644 CHANGES.rst diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..fa24011 --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,2 @@ +## Version 1.1.0 +* Add `MultiProgressManager` class diff --git a/CHANGES.rst b/CHANGES.rst new file mode 100644 index 0000000..d29d4a1 --- /dev/null +++ b/CHANGES.rst @@ -0,0 +1,4 @@ +Version 1.1.0 +------------- + +- Add ``MultiProgressManager`` class diff --git a/README.md b/README.md index 2384d86..e72a565 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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) @@ -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)! diff --git a/README.rst b/README.rst index 34907fc..41a131c 100644 --- a/README.rst +++ b/README.rst @@ -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 @@ -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 @@ -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) `__. You’re welcome to `contribute `__! diff --git a/setup.py b/setup.py index cf5c5b0..f5bb000 100644 --- a/setup.py +++ b/setup.py @@ -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='alimadihib@gmail.com', url='https://github.com/mrunderline/cli-progressbar',