KwPBar for Python

pbar(value, max)
Parameters:
  • value (int/float) – current value of progress bar
  • max (int/float) – maximum value of the progress bar
Raises:

ValueError

Print a progress bar to the screen (stderr).

erase_pbar()

Erase the progress bar from the screen.

get_termlength()
Returns:terminal length, or 80
Return type:int

Return terminal length, internal helper function.

See also

KwPBar for C

Other documents

KwPBar for Python

Info:This is the README file for KwPBar.
Author:Chris Warrick <chris@chriswarrick.com>
Copyright:© 2015-2018, Chris Warrick.
Date:2018-09-03
Version:0.2.1
https://travis-ci.org/Kwpolska/kwpbar.py.svg?branch=master

A simple progress bar for Python programs.

INSTALLATION

pip install kwpbar

USAGE

import kwpbar in your program.

The following functions are available:

  • get_termlength() → return terminal length (columns); helper function
  • pbar(value, max) → print a progress bar to the screen (stderr). Can raise ValueError.
  • erase_pbar() → erase the progress bar from the screen

DEMO

python -m kwpbar.demo

SEE ALSO

KwPBar for C

Appendix A. Contribution rules

Info:Those are the contribution rules for KwPBar.
Copyright:© 2012-2018, Chris Warrick.
License:3-clause BSD

Do you want to contribute to this project? Great! I’d love to see some help, but you must comply with some rules.

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

Issue reporting

GitHub Issues are the recommended way to report an issue.

When pasting console sessions, you must paste them fully, prompt-to-prompt, to see all the messages and your input. Trim only stuff that you are 1000% sure that is not related to the project in question.

General preparations, rules and pull process

Prepare

A GitHub account is recommended. Patches by e-mail are accepted, but I’d prefer to work via GitHub.

Rules
  1. Commits must have short, informative and logical messages. Signoffs and long messages are recommended. “Fix #xxx” is required if an issue exists.
  2. The following fancy Unicode characters should be used when needed: . should not appear in console output, but may appear elsewhere.
  3. For Python code, use the PEP 8 coding style and PEP 257 documentation style. For other languages, K&R style applies. Braces are mandatory in all blocks (even one-line blocks). Braces are on the same lines as class names and function signatures. Use 4-space indents.
Request a Pull

Done? Go hit the Pull Request button over on GitHub! Your request should be accepted shortly (assuming there are no major errors).

Appendix B. License for KwPBar for Python

Info:This is the license for KwPBar for Python.
Author:Chris Warrick <chris@chriswarrick.com>
Copyright:© 2015-2018, Chris Warrick.
License:BSD (see /LICENSE or Appendix B.)
Date:2018-09-03
Version:0.2.1

Copyright © 2015-2018, Chris Warrick. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the author of this software nor the names of contributors to this software may be used to endorse or promote products derived from this software without specific prior written consent.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Appendix C. Changelog

Info:This is the changelog for KwPBar for Python.
Author:Chris Warrick <chris@chriswarrick.com>
Copyright:© 2015-2018, Chris Warrick.
License:BSD (see /LICENSE or Appendix B.)
Date:2018-09-03
Version:0.2.1

GitHub holds releases, too

More information can be found on GitHub in the releases section.

Version History

0.2.1
  • Do not report negative terminal widths
  • Run tests on 3.5 and 3.6
0.2.0
  • Replace subprocess call with shutil.get_terminal_size (on compatible platforms)
0.1.1
  • Add missing MANIFEST.in file
0.1.0
Initial release.
0.2.1
  • Do not report negative terminal widths
  • Run tests on 3.5 and 3.6
0.2.0
  • Replace subprocess call with shutil.get_terminal_size (on compatible platforms)
0.1.1
  • Add missing MANIFEST.in file
0.1.0
Initial release.

Indices and tables