Skip to main content

ProgressPrinter

Code Examples

Progress Bar:

For the full example see examples_progress_bar.py and examples_byte_progress_bar.py

A first really bare version of a html documentation is available here

This will be edited in the next days to make things clearer.

ProgressBar Examples

from time import sleep

from ProgressPrinter import ProgressBar
def ex1():
    pb1 = ProgressBar(100, '%', pre='Downloading file', post='Download finished', length=25)
    pb1.print_progress()  # Prints the initial empty progress bar
    for mb in range(1, 101):
        pb1.print_progress(mb)
        sleep(0.15)
Downloading file
[========================>] - Finished 100 % of 100 %
Download finished
def ex2():
    pb2 = ProgressBar(500, 'MB', pre='Downloading file', post='Download finished', head='#')
    pb2.print_progress()  # Prints the initial empty progress bar
    for mb in range(1, 501):
        pb2.print_progress(mb)
        sleep(0.02)
Downloading file
[=================================================#] - Finished 500 MB of 500 MB
Download finished
def ex3():
    pb3 = ProgressBar(1000.12, 'MB', pre='Downloading file', post='Download finished', length=100)
    pb3.print_progress()  # Prints the initial empty progress bar
    for mb in range(1, 1001):
        if mb != 1000 and mb % 2 == 0:
            mb = mb + 0.5
        elif mb != 1000:
            mb = mb + 0.25
        else:
            mb = mb + 0.12
        pb3.print_progress(mb)
        sleep(0.025)
Downloading file
[===================================================================================================>] - Finished 1000.12 MB of 1000.12 MB
Download finished
def ex4():
    pb4 = ProgressBar(5, 'files', pre='Deleting files', post='Finished!', length=25, empty='*', fill='#')
    pb4.print_progress()  # Prints the initial empty progress bar
    for file in range(1, 6):
        pp4.print_progress(file, pre="Deleting file file{}.txt".format(file))
        sleep(1)
Deleting files
Deleting file file1.txt
Deleting file file2.txt
Deleting file file3.txt
Deleting file file4.txt
Deleting file file5.txt
[########################>] - Finished 5 files of 5 files
Finished!
def ex5():
    with open('example.txt', 'r') as f:
        pb5 = ProgressBar(len(f.readlines()), 'lines', pre="Reading lines from file {}".format(f.name), post='Finished reading file!')
        f.seek(0)  # Return to start of line after obtaining line count
        pb5.print_progress()  # Prints the initial empty progress bar
        for lineno, line in enumerate(f, start=1):
            pb5.print_progress(lineno, pre=line.replace('\n', ''))
            sleep(1)
Reading lines from file example.txt
Line 1
Line 2
Line 3
Line 4
...
[=================================================>] - Finished 5 lines of 5 lines
Finished reading file!

ByteProgressBar Example

import requests

from ProgressPrinter import ByteProgressBar

def ex1():
    # The ByteProgressBar is a extension of the normal progress bar that supports automatic unit conversion
    # from bytes, the base unit you will work with most of the time, to KB, MB, etc.
    # This for example is useful when downloading or working with a file (see example below)
    #
    # UNCOMMENT TO LINK YOU WANT TO USE FOR THE TEST DOWNLOAD
    # -------------------------------------------------------
    # 100MB.bin [100 MB] - Auto conversion to MB
    # link = 'https://speed.hetzner.de/100MB.bin'
    # -------------------------------------------------------------------------------------------
    # Linux Mint Cinnamon x64.iso [ca. 1.87 GB] - Auto conversion to GB
    link = 'http://mirrors.evowise.com/linuxmint/stable/19.2/linuxmint-19.2-cinnamon-64bit.iso'
    # -------------------------------------------------------------------------------------------

    file_name = link.split('/')[-1]
    with open(file_name, 'wb') as f:
        response = requests.get(link, stream=True)
        byte_size = int(response.headers.get('content-length'))
        if byte_size is None:
            f.write(response.content)
        else:
            # Set to ByteProgressBar.UNITS.AUTO to automatically interfere a fitting unit from the byte size
            # -----------------------------------------------------------------------------------------------
            # Supported values: ByteProgressBar.UNITS.{BYTES, KILOBYTES, MEGABYTES, GIGABYTES, TERABYTES, AUTO}

            bpb1 = ByteProgressBar(byte_size, ByteProgressBar.UNITS.AUTO, pre='Downloading {} from {}'
                                   .format(file_name, link), post='Finished download!')
            bpb1.print_progress()
            loaded_bytes = 0
            for chunk in response.iter_content(chunk_size=1048576):  # 1 MB
                loaded_bytes += len(chunk)
                f.write(chunk)
                bpb1.print_progress(loaded_bytes)
Downloading linuxmint-19.2-cinnamon-64bit.iso from http://mirrors.evowise.com/linuxmint/stable/19.2/linuxmint-19.2-cinnamon-64bit.iso
[======>                                           ] - Finished 0.27 GB of 1.87 GB

Metadata

Release files for ProgressPrinter 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ProgressPrinter 0.1.1
File Size Uploaded Provenance
ProgressPrinter-0.1.1.tar.gz 5.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ProgressPrinter 0.1.1
File Interpreter ABI Platform
ProgressPrinter-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.2 kB

Release files / ProgressPrinter-0.1.1.tar.gz

Download URL ProgressPrinter-0.1.1.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9bd17de391dab898f4b423bc9a78479f0856ff2ad65a868ac70bd974d1e5cbc0
BLAKE2b-256 checksum
How to use checksums
2cd2c6c23305804aab174e5374f8846d34a65bd9028ca69c98fc98ee0f478995
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

Release files / ProgressPrinter-0.1.1-py3-none-any.whl

Download URL ProgressPrinter-0.1.1-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5bfa35125390a6412dc7e3c267a93273c2c21f9fd3b266634c3fc89a86c4fb8b
BLAKE2b-256 checksum
How to use checksums
97dc6f918127310301b98a9cf51efe16d5635ae1654e1a0c5bd3d68d2c3fa509
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

Security for ProgressPrinter 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page