diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-05-05 04:02:52 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-05-05 04:02:52 +0000 |
| commit | f7c077af71e1e2c1459fdb7511e7484542bae7ca (patch) | |
| tree | efaebef6c4a9a8d7755cc2aa9823f8eb25f1a6a9 | |
| parent | 1ce9828baed5c5cb46e98d0df6af69204bb7bd17 (diff) | |
automatic import of python-pyprogopeneuler20.03
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | python-pyprog.spec | 1461 | ||||
| -rw-r--r-- | sources | 1 |
3 files changed, 1463 insertions, 0 deletions
@@ -0,0 +1 @@ +/pyprog-1.1.0.post2.tar.gz diff --git a/python-pyprog.spec b/python-pyprog.spec new file mode 100644 index 0000000..b65ec6f --- /dev/null +++ b/python-pyprog.spec @@ -0,0 +1,1461 @@ +%global _empty_manifest_terminate_build 0 +Name: python-pyprog +Version: 1.1.0.post2 +Release: 1 +Summary: A library for creating super customizable progress indicators. +License: GNU AGPLv3 +URL: https://github.com/Bill13579/pyprog +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/8a/13/f61254d7e503fb043cc7a822e9fc67d1eb49556c5c43d1f3501e0407f7db/pyprog-1.1.0.post2.tar.gz +BuildArch: noarch + + +%description +# Introduction + +PyProg is an Open-Source library for creating progress indicators (e.g. progress bars). It helps you create customizable progress indicators. This library is for Python. + +# Compatibility + +PyProg is compatible with both Python 3 and Python 2, and will also work on Qt Console. + +# Getting Started + +## Installation + +Latest Release: `pip install pyprog` + +Latest Development Release: `pip install git+https://github.com/Bill13579/pyprog.git@develop` + +After you have installed PyProg, you can test if it has been successfully installed by running `import pyprog` in python. If PyProg was installed successfully, it should show no errors. + +## How to use the PyProg Progress Bar + +### Basic PyProg Progress Bar + +To create a basic progress bar, follow these steps: + +1. Install PyProg ([Guide](#installation "How to install PyProg")) +2. Import PyProg: `import pyprog` +3. Create a `ProgressBar` object: `prog = pyprog.ProgressBar("", "")` +4. Show the bar: `prog.update()` +5. To update the status, use `prog.set_stat(<status>)` to set the status and then use `prog.update()` to actually show the change +6. When finished, use `prog.end()` to make the Progress Bar last + +Example Code with Fake For loop: + +```python +import pyprog +from time import sleep + +# Create a PyProg ProgressBar Object +prog = pyprog.ProgressBar(":-) ", " OK!") + +# Show the initial status +prog.update() + +# Fake for loop +for i in range(0, 100): + + # Sleep for a while (This is just to slow down the for loop so that it won't end in an instant) + sleep(0.1) + + # Update status + prog.set_stat(i + 1) + + # Show (Update) the current status + prog.update() + +# Make the Progress Bar final +prog.end() +``` + +Output: + +``` +Initial State: +:-) Progress: 0% -------------------------------------------------- OK! + +When progress is 50: +:-) Progress: 50% #########################------------------------- OK! + +Final State: +:-) Progress: 100% ################################################## OK! +``` + +#### What is the first two parameters? + +The first two parameters in `prog = pyprog.ProgressBar("", "")` is for telling PyProg what to put before and after the progress indicator. + +Example: + +``` + :-) Progress: 0% -------------------------------------------------- OK! + ^ ^ ^ +Prefix Bar Suffix +``` + +### Pretty Progress Bar + +You can also add more options to make it look good. + +Adding options `complete_symbol="█", not_complete_symbol="-"` will change the original output to: + +``` +Initial State: +:-) Progress: 0% -------------------------------------------------- OK! + +When progress is 50: +:-) Progress: 50% █████████████████████████------------------------- OK! + +Final State: +:-) Progress: 100% ██████████████████████████████████████████████████ OK! +``` + +### Auto calculate the percentage + +PyProg can also auto calculate the current percentage. You just need to tell PyProg the total number of things you need to process. + +Change the line `prog = pyprog.ProgressBar("", "")` to `prog = pyprog.ProgressBar("", "", <Total Number of things>)`, and PyProg will calculate the percentage for you based on the status that you give it. + +To use it in our simple progress bar code, if we have 37 tasks to do, we can change this: + +```python +# Create a PyProg ProgressBar Object +prog = pyprog.ProgressBar(":-) ", " OK!") +``` + +to this: + +```python +# Create a PyProg ProgressBar Object +prog = pyprog.ProgressBar(":-) ", " OK!", 37) +``` + +And also change the fake for loop from `for i in range(0, 100):` to `for i in range(0, 37):`, and it will auto calculate the percentage and show it to the user. + +## How to use the PyProg Progress Indicator (Fraction) + +### Basic PyProg Progress Indicator (Fraction) + +To create a basic progress indicator (fraction), follow these steps: + +1. Import PyProg: `import pyprog` +2. Create a `ProgressIndicatorFraction` object: `prog = pyprog.ProgressIndicatorFraction("", "", <Total number of things>)` (Replace "<Total number of things>" with the total number of tasks or things you need to process) +3. Show the indicator: `prog.update()` +4. To update the status, use `prog.set_stat(<status>)` to set the status and then use `prog.update()` to actually show the change +5. When finished, use `prog.end()` to make the Progress Indicator (Fraction) last + +Example Code with Fake For loop (We are using 56 as the total in this example): + +```python +import pyprog +from time import sleep + +# Create a PyProg ProgressIndicatorFraction Object +prog = pyprog.ProgressIndicatorFraction(":-) ", " OK!", 56) + +# Show the initial status +prog.update() + +# Fake for loop +for i in range(0, 56): + + # Sleep for a while (This is just to slow down the for loop so that it won't end in an instant) + sleep(0.1) + + # Update status + prog.set_stat(i + 1) + + # Show (Update) the current status + prog.update() + +# Make the Progress Indicator (Fraction) final +prog.end() +``` + +Output: + +``` +Initial State: +:-) 0/56 OK! + +When half done: +:-) 28/56 OK! + +Final State: +:-) 56/56 OK! +``` + +# Documentation + +## Progress Indicator Parameters + +### Options for ProgressBar + +#### prefix + +The prefix of everything. + +#### suffix + +The suffix of everything. + +#### total (default is 100) + +This is the option that tells PyProg how many things or tasks you need to process. We used it in the [Auto calculate the percentage](#auto-calculate-the-percentage "Auto calculate the percentage") section. + +#### bar_length (default is 50) + +This tells PyProg how long should the bar should be. + +#### initial (default is 0) + +Initial status to show on the bar. + +#### decimals (default is 0) + +How many decimals should the percent have. + +#### complete_symbol (default is "#") + +The complete symbol will be shown in the complete part of the bar. We used it in the [Pretty Progress Bar](#pretty-progress-bar "Pretty Progress Bar") section. + +Example Position of complete symbol: +Progress: 59% <span style="background-color: #FFFF00">#############################</span>--------------------- + +#### not_complete_symbol (default is "-") + +The not complete symbol will be shown in the not yet complete part of the bar. We used it in the [Pretty Progress Bar](#pretty-progress-bar "Pretty Progress Bar") section. + +Example Position of complete symbol: +Progress: 59% #############################<span style="background-color: #FFFF00">---------------------</span> + +#### progress_loc (default is 0) + +Where the progress explanation (prefix) and the progress text should be shown. + +Possible Values:<br/> + ProgressBar.PROGRESS_LOC_START or 0 - Show both at the start<br/> + ProgressBar.PROGRESS_LOC_MIDDLE or 1 - Show both at the middle of the bar<br/> + ProgressBar.PROGRESS_LOC_END or 2 - Show both at the end<br/> + ProgressBar.PROGRESS_LOC_EXP_START_PROGRESS_MID or 3 - Show explanation (prefix) at the start and the progress text at the middle of the bar<br/> + ProgressBar.PROGRESS_LOC_EXP_END_PROGRESS_MID or 4 - Show explanation (prefix) at the end and the progress text at the middle of the bar + +PROGRESS_LOC_START:<br/> +<span style="background-color: #FFFF00">Progress: 32%</span> ################---------------------------------- + +PROGRESS_LOC_MIDDLE:<br/> +\################ <span style="background-color: #FFFF00">Progress: 32%</span> ------------------ + +PROGRESS_LOC_END:<br/> +\################---------------------------------- <span style="background-color: #FFFF00">Progress: 32%</span> + +PROGRESS_LOC_EXP_START_PROGRESS_MID:<br/> +<span style="background-color: #FFFF00">Progress: </span>################----- <span style="background-color: #FFFF00">32%</span> ----------------------- + +PROGRESS_LOC_EXP_END_PROGRESS_MID:<br/> +\################----- <span style="background-color: #FFFF00">32%</span> ----------------------- <span style="background-color: #FFFF00">Progress: </span> + +#### progress_format (default is "+p%") + +Format for the progress text. PyProg replaces special characters with actual values. Here is a list of special characters: + +"+p" -> Current percent<br/> +"+c" -> Current status + +#### progress_explain (default is "Progress: ") + +This is the progress explanation (prefix). + +Example position of progress explanation: +<span style="background-color: #FFFF00">Progress: </span>32% ################---------------------------------- + +Examples:<br/> + "Progress: "<br/> + "Current Progress: " + +#### wrap_bar_prefix (default is " ") + +The prefix of the bar. + +#### wrap_bar_suffix (default is " ") + +The suffix of the bar. + +### Options for ProgressIndicatorFraction + +#### prefix + +The prefix of everything. + +#### suffix + +The suffix of everything. + +#### total + +This is the option that tells PyProg how many things or tasks you need to process. + +#### initial (default is 0) + +Initial status to show on the indicator. + +## Progress Indicator Functions + +### Functions for ProgressBar + +#### set_stat() + +Available on: PyProg 1.0.0 ~<br/> +Params: current + +Set the current progress. + +#### stat() + +Available on: PyProg 1.1.0-0 ~<br/> +Params: current<br/> +Note: This function is currently only available on the ProgressBar. Support for ProgressIndicatorFraction will come soon. + +Set the current progress and update the progress bar. + +#### progress() + +Available on: PyProg 1.1.0-0 ~<br/> +Params: progress<br/> +Note: This function is currently only available on the ProgressBar. Support for ProgressIndicatorFraction will come soon. + +Increase the progress by the given amount. + +#### update() + +Available on: PyProg 1.0.0 ~<br/> +Params: (none) + +Update the progress bar so that it shows the current progress.<br/> +Note: Also call this to initiate the bar. + +#### end() + +Available on: PyProg 1.0.0 ~<br/> +Params: (none) + +End the progress bar. + +#### end_m() + +Available on: PyProg 1.1.0-0 ~<br/> +Params: msg<br/> +Note: This function is currently only available on the ProgressBar. Support for ProgressIndicatorFraction will come soon. + +End the progress bar with a message. + +#### set_prefix() + +Available on: PyProg 1.0.0 ~<br/> +Params: prefix + +Set the prefix + +#### set_suffix() + +Available on: PyProg 1.0.0 ~<br/> +Params: suffix + +Set the suffix + +#### set_total() + +Available on: PyProg 1.0.0 ~<br/> +Params: total + +Set the total + +#### set_bar_length() + +Available on: PyProg 1.0.0 ~<br/> +Params: bar_length + +Set the length of the bar + +#### set_decimals() + +Available on: PyProg 1.0.0 ~<br/> +Params: decimals + +Set the number of decimals for the percent + +#### set_symbols() + +Available on: PyProg 1.0.0 ~<br/> +Params: symbols + +Set the complete symbol and the not complete symbol. `symbols` has to be a tuple: (complete symbol, not complete symbol) + +#### set_progress_loc() + +Available on: PyProg 1.0.0 ~<br/> +Params: progress_loc + +Set the progress explanation (prefix) and the progress text location. See [the progress_loc parameter](#user-content-progress_loc-default-is-0 "progress_loc") section for the possible values. + +#### set_progress_explain() + +Available on: PyProg 1.0.0 ~<br/> +Params: progress_explain + +Set the progress explanation (prefix). + +Examples:<br/> + "Progress: "<br/> + "Current Progress: " + +#### set_wrap_bar_text() + +Available on: PyProg 1.0.0 ~<br/> +Params: prefix, suffix + +Set the wrap bar text (the prefix and the suffix of the bar). + +#### set_progress_format() + +Available on: PyProg 1.0.0 ~<br/> +Params: progress_format + +Set the format for the progress text. PyProg replaces special characters with actual values. Here is a list of special characters: + +"+p" -> Current percent<br/> +"+c" -> Current status + +### Functions for ProgressIndicatorFunction + +#### set_stat() + +Available on: PyProg 1.0.0 ~<br/> +Params: current + +Set the current progress. + +#### update() + +Available on: PyProg 1.0.0 ~<br/> +Params: (none) + +Update the progress indicator so that it shows the current progress. +Note: Also call this to initiate the indicator. + +#### end() + +Available on: PyProg 1.0.0 ~<br/> +Params: (none) + +End the progress indicator. + +#### set_prefix() + +Available on: PyProg 1.0.0 ~<br/> +Params: prefix + +Set the prefix + +#### set_suffix() + +Available on: PyProg 1.0.0 ~<br/> +Params: suffix + +Set the suffix + +#### set_total() + +Available on: PyProg 1.0.0 ~<br/> +Params: total + +Set the total + + + + +%package -n python3-pyprog +Summary: A library for creating super customizable progress indicators. +Provides: python-pyprog +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-pyprog +# Introduction + +PyProg is an Open-Source library for creating progress indicators (e.g. progress bars). It helps you create customizable progress indicators. This library is for Python. + +# Compatibility + +PyProg is compatible with both Python 3 and Python 2, and will also work on Qt Console. + +# Getting Started + +## Installation + +Latest Release: `pip install pyprog` + +Latest Development Release: `pip install git+https://github.com/Bill13579/pyprog.git@develop` + +After you have installed PyProg, you can test if it has been successfully installed by running `import pyprog` in python. If PyProg was installed successfully, it should show no errors. + +## How to use the PyProg Progress Bar + +### Basic PyProg Progress Bar + +To create a basic progress bar, follow these steps: + +1. Install PyProg ([Guide](#installation "How to install PyProg")) +2. Import PyProg: `import pyprog` +3. Create a `ProgressBar` object: `prog = pyprog.ProgressBar("", "")` +4. Show the bar: `prog.update()` +5. To update the status, use `prog.set_stat(<status>)` to set the status and then use `prog.update()` to actually show the change +6. When finished, use `prog.end()` to make the Progress Bar last + +Example Code with Fake For loop: + +```python +import pyprog +from time import sleep + +# Create a PyProg ProgressBar Object +prog = pyprog.ProgressBar(":-) ", " OK!") + +# Show the initial status +prog.update() + +# Fake for loop +for i in range(0, 100): + + # Sleep for a while (This is just to slow down the for loop so that it won't end in an instant) + sleep(0.1) + + # Update status + prog.set_stat(i + 1) + + # Show (Update) the current status + prog.update() + +# Make the Progress Bar final +prog.end() +``` + +Output: + +``` +Initial State: +:-) Progress: 0% -------------------------------------------------- OK! + +When progress is 50: +:-) Progress: 50% #########################------------------------- OK! + +Final State: +:-) Progress: 100% ################################################## OK! +``` + +#### What is the first two parameters? + +The first two parameters in `prog = pyprog.ProgressBar("", "")` is for telling PyProg what to put before and after the progress indicator. + +Example: + +``` + :-) Progress: 0% -------------------------------------------------- OK! + ^ ^ ^ +Prefix Bar Suffix +``` + +### Pretty Progress Bar + +You can also add more options to make it look good. + +Adding options `complete_symbol="█", not_complete_symbol="-"` will change the original output to: + +``` +Initial State: +:-) Progress: 0% -------------------------------------------------- OK! + +When progress is 50: +:-) Progress: 50% █████████████████████████------------------------- OK! + +Final State: +:-) Progress: 100% ██████████████████████████████████████████████████ OK! +``` + +### Auto calculate the percentage + +PyProg can also auto calculate the current percentage. You just need to tell PyProg the total number of things you need to process. + +Change the line `prog = pyprog.ProgressBar("", "")` to `prog = pyprog.ProgressBar("", "", <Total Number of things>)`, and PyProg will calculate the percentage for you based on the status that you give it. + +To use it in our simple progress bar code, if we have 37 tasks to do, we can change this: + +```python +# Create a PyProg ProgressBar Object +prog = pyprog.ProgressBar(":-) ", " OK!") +``` + +to this: + +```python +# Create a PyProg ProgressBar Object +prog = pyprog.ProgressBar(":-) ", " OK!", 37) +``` + +And also change the fake for loop from `for i in range(0, 100):` to `for i in range(0, 37):`, and it will auto calculate the percentage and show it to the user. + +## How to use the PyProg Progress Indicator (Fraction) + +### Basic PyProg Progress Indicator (Fraction) + +To create a basic progress indicator (fraction), follow these steps: + +1. Import PyProg: `import pyprog` +2. Create a `ProgressIndicatorFraction` object: `prog = pyprog.ProgressIndicatorFraction("", "", <Total number of things>)` (Replace "<Total number of things>" with the total number of tasks or things you need to process) +3. Show the indicator: `prog.update()` +4. To update the status, use `prog.set_stat(<status>)` to set the status and then use `prog.update()` to actually show the change +5. When finished, use `prog.end()` to make the Progress Indicator (Fraction) last + +Example Code with Fake For loop (We are using 56 as the total in this example): + +```python +import pyprog +from time import sleep + +# Create a PyProg ProgressIndicatorFraction Object +prog = pyprog.ProgressIndicatorFraction(":-) ", " OK!", 56) + +# Show the initial status +prog.update() + +# Fake for loop +for i in range(0, 56): + + # Sleep for a while (This is just to slow down the for loop so that it won't end in an instant) + sleep(0.1) + + # Update status + prog.set_stat(i + 1) + + # Show (Update) the current status + prog.update() + +# Make the Progress Indicator (Fraction) final +prog.end() +``` + +Output: + +``` +Initial State: +:-) 0/56 OK! + +When half done: +:-) 28/56 OK! + +Final State: +:-) 56/56 OK! +``` + +# Documentation + +## Progress Indicator Parameters + +### Options for ProgressBar + +#### prefix + +The prefix of everything. + +#### suffix + +The suffix of everything. + +#### total (default is 100) + +This is the option that tells PyProg how many things or tasks you need to process. We used it in the [Auto calculate the percentage](#auto-calculate-the-percentage "Auto calculate the percentage") section. + +#### bar_length (default is 50) + +This tells PyProg how long should the bar should be. + +#### initial (default is 0) + +Initial status to show on the bar. + +#### decimals (default is 0) + +How many decimals should the percent have. + +#### complete_symbol (default is "#") + +The complete symbol will be shown in the complete part of the bar. We used it in the [Pretty Progress Bar](#pretty-progress-bar "Pretty Progress Bar") section. + +Example Position of complete symbol: +Progress: 59% <span style="background-color: #FFFF00">#############################</span>--------------------- + +#### not_complete_symbol (default is "-") + +The not complete symbol will be shown in the not yet complete part of the bar. We used it in the [Pretty Progress Bar](#pretty-progress-bar "Pretty Progress Bar") section. + +Example Position of complete symbol: +Progress: 59% #############################<span style="background-color: #FFFF00">---------------------</span> + +#### progress_loc (default is 0) + +Where the progress explanation (prefix) and the progress text should be shown. + +Possible Values:<br/> + ProgressBar.PROGRESS_LOC_START or 0 - Show both at the start<br/> + ProgressBar.PROGRESS_LOC_MIDDLE or 1 - Show both at the middle of the bar<br/> + ProgressBar.PROGRESS_LOC_END or 2 - Show both at the end<br/> + ProgressBar.PROGRESS_LOC_EXP_START_PROGRESS_MID or 3 - Show explanation (prefix) at the start and the progress text at the middle of the bar<br/> + ProgressBar.PROGRESS_LOC_EXP_END_PROGRESS_MID or 4 - Show explanation (prefix) at the end and the progress text at the middle of the bar + +PROGRESS_LOC_START:<br/> +<span style="background-color: #FFFF00">Progress: 32%</span> ################---------------------------------- + +PROGRESS_LOC_MIDDLE:<br/> +\################ <span style="background-color: #FFFF00">Progress: 32%</span> ------------------ + +PROGRESS_LOC_END:<br/> +\################---------------------------------- <span style="background-color: #FFFF00">Progress: 32%</span> + +PROGRESS_LOC_EXP_START_PROGRESS_MID:<br/> +<span style="background-color: #FFFF00">Progress: </span>################----- <span style="background-color: #FFFF00">32%</span> ----------------------- + +PROGRESS_LOC_EXP_END_PROGRESS_MID:<br/> +\################----- <span style="background-color: #FFFF00">32%</span> ----------------------- <span style="background-color: #FFFF00">Progress: </span> + +#### progress_format (default is "+p%") + +Format for the progress text. PyProg replaces special characters with actual values. Here is a list of special characters: + +"+p" -> Current percent<br/> +"+c" -> Current status + +#### progress_explain (default is "Progress: ") + +This is the progress explanation (prefix). + +Example position of progress explanation: +<span style="background-color: #FFFF00">Progress: </span>32% ################---------------------------------- + +Examples:<br/> + "Progress: "<br/> + "Current Progress: " + +#### wrap_bar_prefix (default is " ") + +The prefix of the bar. + +#### wrap_bar_suffix (default is " ") + +The suffix of the bar. + +### Options for ProgressIndicatorFraction + +#### prefix + +The prefix of everything. + +#### suffix + +The suffix of everything. + +#### total + +This is the option that tells PyProg how many things or tasks you need to process. + +#### initial (default is 0) + +Initial status to show on the indicator. + +## Progress Indicator Functions + +### Functions for ProgressBar + +#### set_stat() + +Available on: PyProg 1.0.0 ~<br/> +Params: current + +Set the current progress. + +#### stat() + +Available on: PyProg 1.1.0-0 ~<br/> +Params: current<br/> +Note: This function is currently only available on the ProgressBar. Support for ProgressIndicatorFraction will come soon. + +Set the current progress and update the progress bar. + +#### progress() + +Available on: PyProg 1.1.0-0 ~<br/> +Params: progress<br/> +Note: This function is currently only available on the ProgressBar. Support for ProgressIndicatorFraction will come soon. + +Increase the progress by the given amount. + +#### update() + +Available on: PyProg 1.0.0 ~<br/> +Params: (none) + +Update the progress bar so that it shows the current progress.<br/> +Note: Also call this to initiate the bar. + +#### end() + +Available on: PyProg 1.0.0 ~<br/> +Params: (none) + +End the progress bar. + +#### end_m() + +Available on: PyProg 1.1.0-0 ~<br/> +Params: msg<br/> +Note: This function is currently only available on the ProgressBar. Support for ProgressIndicatorFraction will come soon. + +End the progress bar with a message. + +#### set_prefix() + +Available on: PyProg 1.0.0 ~<br/> +Params: prefix + +Set the prefix + +#### set_suffix() + +Available on: PyProg 1.0.0 ~<br/> +Params: suffix + +Set the suffix + +#### set_total() + +Available on: PyProg 1.0.0 ~<br/> +Params: total + +Set the total + +#### set_bar_length() + +Available on: PyProg 1.0.0 ~<br/> +Params: bar_length + +Set the length of the bar + +#### set_decimals() + +Available on: PyProg 1.0.0 ~<br/> +Params: decimals + +Set the number of decimals for the percent + +#### set_symbols() + +Available on: PyProg 1.0.0 ~<br/> +Params: symbols + +Set the complete symbol and the not complete symbol. `symbols` has to be a tuple: (complete symbol, not complete symbol) + +#### set_progress_loc() + +Available on: PyProg 1.0.0 ~<br/> +Params: progress_loc + +Set the progress explanation (prefix) and the progress text location. See [the progress_loc parameter](#user-content-progress_loc-default-is-0 "progress_loc") section for the possible values. + +#### set_progress_explain() + +Available on: PyProg 1.0.0 ~<br/> +Params: progress_explain + +Set the progress explanation (prefix). + +Examples:<br/> + "Progress: "<br/> + "Current Progress: " + +#### set_wrap_bar_text() + +Available on: PyProg 1.0.0 ~<br/> +Params: prefix, suffix + +Set the wrap bar text (the prefix and the suffix of the bar). + +#### set_progress_format() + +Available on: PyProg 1.0.0 ~<br/> +Params: progress_format + +Set the format for the progress text. PyProg replaces special characters with actual values. Here is a list of special characters: + +"+p" -> Current percent<br/> +"+c" -> Current status + +### Functions for ProgressIndicatorFunction + +#### set_stat() + +Available on: PyProg 1.0.0 ~<br/> +Params: current + +Set the current progress. + +#### update() + +Available on: PyProg 1.0.0 ~<br/> +Params: (none) + +Update the progress indicator so that it shows the current progress. +Note: Also call this to initiate the indicator. + +#### end() + +Available on: PyProg 1.0.0 ~<br/> +Params: (none) + +End the progress indicator. + +#### set_prefix() + +Available on: PyProg 1.0.0 ~<br/> +Params: prefix + +Set the prefix + +#### set_suffix() + +Available on: PyProg 1.0.0 ~<br/> +Params: suffix + +Set the suffix + +#### set_total() + +Available on: PyProg 1.0.0 ~<br/> +Params: total + +Set the total + + + + +%package help +Summary: Development documents and examples for pyprog +Provides: python3-pyprog-doc +%description help +# Introduction + +PyProg is an Open-Source library for creating progress indicators (e.g. progress bars). It helps you create customizable progress indicators. This library is for Python. + +# Compatibility + +PyProg is compatible with both Python 3 and Python 2, and will also work on Qt Console. + +# Getting Started + +## Installation + +Latest Release: `pip install pyprog` + +Latest Development Release: `pip install git+https://github.com/Bill13579/pyprog.git@develop` + +After you have installed PyProg, you can test if it has been successfully installed by running `import pyprog` in python. If PyProg was installed successfully, it should show no errors. + +## How to use the PyProg Progress Bar + +### Basic PyProg Progress Bar + +To create a basic progress bar, follow these steps: + +1. Install PyProg ([Guide](#installation "How to install PyProg")) +2. Import PyProg: `import pyprog` +3. Create a `ProgressBar` object: `prog = pyprog.ProgressBar("", "")` +4. Show the bar: `prog.update()` +5. To update the status, use `prog.set_stat(<status>)` to set the status and then use `prog.update()` to actually show the change +6. When finished, use `prog.end()` to make the Progress Bar last + +Example Code with Fake For loop: + +```python +import pyprog +from time import sleep + +# Create a PyProg ProgressBar Object +prog = pyprog.ProgressBar(":-) ", " OK!") + +# Show the initial status +prog.update() + +# Fake for loop +for i in range(0, 100): + + # Sleep for a while (This is just to slow down the for loop so that it won't end in an instant) + sleep(0.1) + + # Update status + prog.set_stat(i + 1) + + # Show (Update) the current status + prog.update() + +# Make the Progress Bar final +prog.end() +``` + +Output: + +``` +Initial State: +:-) Progress: 0% -------------------------------------------------- OK! + +When progress is 50: +:-) Progress: 50% #########################------------------------- OK! + +Final State: +:-) Progress: 100% ################################################## OK! +``` + +#### What is the first two parameters? + +The first two parameters in `prog = pyprog.ProgressBar("", "")` is for telling PyProg what to put before and after the progress indicator. + +Example: + +``` + :-) Progress: 0% -------------------------------------------------- OK! + ^ ^ ^ +Prefix Bar Suffix +``` + +### Pretty Progress Bar + +You can also add more options to make it look good. + +Adding options `complete_symbol="█", not_complete_symbol="-"` will change the original output to: + +``` +Initial State: +:-) Progress: 0% -------------------------------------------------- OK! + +When progress is 50: +:-) Progress: 50% █████████████████████████------------------------- OK! + +Final State: +:-) Progress: 100% ██████████████████████████████████████████████████ OK! +``` + +### Auto calculate the percentage + +PyProg can also auto calculate the current percentage. You just need to tell PyProg the total number of things you need to process. + +Change the line `prog = pyprog.ProgressBar("", "")` to `prog = pyprog.ProgressBar("", "", <Total Number of things>)`, and PyProg will calculate the percentage for you based on the status that you give it. + +To use it in our simple progress bar code, if we have 37 tasks to do, we can change this: + +```python +# Create a PyProg ProgressBar Object +prog = pyprog.ProgressBar(":-) ", " OK!") +``` + +to this: + +```python +# Create a PyProg ProgressBar Object +prog = pyprog.ProgressBar(":-) ", " OK!", 37) +``` + +And also change the fake for loop from `for i in range(0, 100):` to `for i in range(0, 37):`, and it will auto calculate the percentage and show it to the user. + +## How to use the PyProg Progress Indicator (Fraction) + +### Basic PyProg Progress Indicator (Fraction) + +To create a basic progress indicator (fraction), follow these steps: + +1. Import PyProg: `import pyprog` +2. Create a `ProgressIndicatorFraction` object: `prog = pyprog.ProgressIndicatorFraction("", "", <Total number of things>)` (Replace "<Total number of things>" with the total number of tasks or things you need to process) +3. Show the indicator: `prog.update()` +4. To update the status, use `prog.set_stat(<status>)` to set the status and then use `prog.update()` to actually show the change +5. When finished, use `prog.end()` to make the Progress Indicator (Fraction) last + +Example Code with Fake For loop (We are using 56 as the total in this example): + +```python +import pyprog +from time import sleep + +# Create a PyProg ProgressIndicatorFraction Object +prog = pyprog.ProgressIndicatorFraction(":-) ", " OK!", 56) + +# Show the initial status +prog.update() + +# Fake for loop +for i in range(0, 56): + + # Sleep for a while (This is just to slow down the for loop so that it won't end in an instant) + sleep(0.1) + + # Update status + prog.set_stat(i + 1) + + # Show (Update) the current status + prog.update() + +# Make the Progress Indicator (Fraction) final +prog.end() +``` + +Output: + +``` +Initial State: +:-) 0/56 OK! + +When half done: +:-) 28/56 OK! + +Final State: +:-) 56/56 OK! +``` + +# Documentation + +## Progress Indicator Parameters + +### Options for ProgressBar + +#### prefix + +The prefix of everything. + +#### suffix + +The suffix of everything. + +#### total (default is 100) + +This is the option that tells PyProg how many things or tasks you need to process. We used it in the [Auto calculate the percentage](#auto-calculate-the-percentage "Auto calculate the percentage") section. + +#### bar_length (default is 50) + +This tells PyProg how long should the bar should be. + +#### initial (default is 0) + +Initial status to show on the bar. + +#### decimals (default is 0) + +How many decimals should the percent have. + +#### complete_symbol (default is "#") + +The complete symbol will be shown in the complete part of the bar. We used it in the [Pretty Progress Bar](#pretty-progress-bar "Pretty Progress Bar") section. + +Example Position of complete symbol: +Progress: 59% <span style="background-color: #FFFF00">#############################</span>--------------------- + +#### not_complete_symbol (default is "-") + +The not complete symbol will be shown in the not yet complete part of the bar. We used it in the [Pretty Progress Bar](#pretty-progress-bar "Pretty Progress Bar") section. + +Example Position of complete symbol: +Progress: 59% #############################<span style="background-color: #FFFF00">---------------------</span> + +#### progress_loc (default is 0) + +Where the progress explanation (prefix) and the progress text should be shown. + +Possible Values:<br/> + ProgressBar.PROGRESS_LOC_START or 0 - Show both at the start<br/> + ProgressBar.PROGRESS_LOC_MIDDLE or 1 - Show both at the middle of the bar<br/> + ProgressBar.PROGRESS_LOC_END or 2 - Show both at the end<br/> + ProgressBar.PROGRESS_LOC_EXP_START_PROGRESS_MID or 3 - Show explanation (prefix) at the start and the progress text at the middle of the bar<br/> + ProgressBar.PROGRESS_LOC_EXP_END_PROGRESS_MID or 4 - Show explanation (prefix) at the end and the progress text at the middle of the bar + +PROGRESS_LOC_START:<br/> +<span style="background-color: #FFFF00">Progress: 32%</span> ################---------------------------------- + +PROGRESS_LOC_MIDDLE:<br/> +\################ <span style="background-color: #FFFF00">Progress: 32%</span> ------------------ + +PROGRESS_LOC_END:<br/> +\################---------------------------------- <span style="background-color: #FFFF00">Progress: 32%</span> + +PROGRESS_LOC_EXP_START_PROGRESS_MID:<br/> +<span style="background-color: #FFFF00">Progress: </span>################----- <span style="background-color: #FFFF00">32%</span> ----------------------- + +PROGRESS_LOC_EXP_END_PROGRESS_MID:<br/> +\################----- <span style="background-color: #FFFF00">32%</span> ----------------------- <span style="background-color: #FFFF00">Progress: </span> + +#### progress_format (default is "+p%") + +Format for the progress text. PyProg replaces special characters with actual values. Here is a list of special characters: + +"+p" -> Current percent<br/> +"+c" -> Current status + +#### progress_explain (default is "Progress: ") + +This is the progress explanation (prefix). + +Example position of progress explanation: +<span style="background-color: #FFFF00">Progress: </span>32% ################---------------------------------- + +Examples:<br/> + "Progress: "<br/> + "Current Progress: " + +#### wrap_bar_prefix (default is " ") + +The prefix of the bar. + +#### wrap_bar_suffix (default is " ") + +The suffix of the bar. + +### Options for ProgressIndicatorFraction + +#### prefix + +The prefix of everything. + +#### suffix + +The suffix of everything. + +#### total + +This is the option that tells PyProg how many things or tasks you need to process. + +#### initial (default is 0) + +Initial status to show on the indicator. + +## Progress Indicator Functions + +### Functions for ProgressBar + +#### set_stat() + +Available on: PyProg 1.0.0 ~<br/> +Params: current + +Set the current progress. + +#### stat() + +Available on: PyProg 1.1.0-0 ~<br/> +Params: current<br/> +Note: This function is currently only available on the ProgressBar. Support for ProgressIndicatorFraction will come soon. + +Set the current progress and update the progress bar. + +#### progress() + +Available on: PyProg 1.1.0-0 ~<br/> +Params: progress<br/> +Note: This function is currently only available on the ProgressBar. Support for ProgressIndicatorFraction will come soon. + +Increase the progress by the given amount. + +#### update() + +Available on: PyProg 1.0.0 ~<br/> +Params: (none) + +Update the progress bar so that it shows the current progress.<br/> +Note: Also call this to initiate the bar. + +#### end() + +Available on: PyProg 1.0.0 ~<br/> +Params: (none) + +End the progress bar. + +#### end_m() + +Available on: PyProg 1.1.0-0 ~<br/> +Params: msg<br/> +Note: This function is currently only available on the ProgressBar. Support for ProgressIndicatorFraction will come soon. + +End the progress bar with a message. + +#### set_prefix() + +Available on: PyProg 1.0.0 ~<br/> +Params: prefix + +Set the prefix + +#### set_suffix() + +Available on: PyProg 1.0.0 ~<br/> +Params: suffix + +Set the suffix + +#### set_total() + +Available on: PyProg 1.0.0 ~<br/> +Params: total + +Set the total + +#### set_bar_length() + +Available on: PyProg 1.0.0 ~<br/> +Params: bar_length + +Set the length of the bar + +#### set_decimals() + +Available on: PyProg 1.0.0 ~<br/> +Params: decimals + +Set the number of decimals for the percent + +#### set_symbols() + +Available on: PyProg 1.0.0 ~<br/> +Params: symbols + +Set the complete symbol and the not complete symbol. `symbols` has to be a tuple: (complete symbol, not complete symbol) + +#### set_progress_loc() + +Available on: PyProg 1.0.0 ~<br/> +Params: progress_loc + +Set the progress explanation (prefix) and the progress text location. See [the progress_loc parameter](#user-content-progress_loc-default-is-0 "progress_loc") section for the possible values. + +#### set_progress_explain() + +Available on: PyProg 1.0.0 ~<br/> +Params: progress_explain + +Set the progress explanation (prefix). + +Examples:<br/> + "Progress: "<br/> + "Current Progress: " + +#### set_wrap_bar_text() + +Available on: PyProg 1.0.0 ~<br/> +Params: prefix, suffix + +Set the wrap bar text (the prefix and the suffix of the bar). + +#### set_progress_format() + +Available on: PyProg 1.0.0 ~<br/> +Params: progress_format + +Set the format for the progress text. PyProg replaces special characters with actual values. Here is a list of special characters: + +"+p" -> Current percent<br/> +"+c" -> Current status + +### Functions for ProgressIndicatorFunction + +#### set_stat() + +Available on: PyProg 1.0.0 ~<br/> +Params: current + +Set the current progress. + +#### update() + +Available on: PyProg 1.0.0 ~<br/> +Params: (none) + +Update the progress indicator so that it shows the current progress. +Note: Also call this to initiate the indicator. + +#### end() + +Available on: PyProg 1.0.0 ~<br/> +Params: (none) + +End the progress indicator. + +#### set_prefix() + +Available on: PyProg 1.0.0 ~<br/> +Params: prefix + +Set the prefix + +#### set_suffix() + +Available on: PyProg 1.0.0 ~<br/> +Params: suffix + +Set the suffix + +#### set_total() + +Available on: PyProg 1.0.0 ~<br/> +Params: total + +Set the total + + + + +%prep +%autosetup -n pyprog-1.1.0.post2 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-pyprog -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 1.1.0.post2-1 +- Package Spec generated @@ -0,0 +1 @@ +27384b593ce69755c89f6b6ea0d8eb9c pyprog-1.1.0.post2.tar.gz |
