Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

barkeep

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

barkeep

  • 0.1.4
  • PyPI
  • Socket score

Maintainers
1

Small, C++-based python library to display async animations, counters, and progress bars.

Build status pypi

Installation: pip install barkeep


  • Display a waiting animation with a message:

    import time
    import barkeep as bk
    
    anim = bk.Animation(message="Working")
    anim.show()
    time.sleep(10)  # do work
    anim.done()
    
  • Supports several styles:

    anim = bk.Animation(message="Working", style=bk.Earth)
    
  • Display a counter to monitor a numeric variable while waiting:

    c = bk.Counter(message="Reading lines", speed=1.0, speed_unit="line/s")
    c.show()
    for i in range(505):
        time.sleep(0.013)  # read & process line
        c += 1
    c.done()
    
  • Display a progress bar to monitor a numeric variable and measure its completion by comparing against a total:

    bar = bk.ProgressBar(message="Reading lines", speed=1.0, speed_unit="line/s", total=505)
    bar.show()
    for i in range(505):
        time.sleep(0.013)  # read & process line
        bar += 1
    bar.done()
    
  • Combine diplays using | operator to monitor multiple variables:

    import random
    
    sents = bk.ProgressBar(total=1010, message="Sents")
    toks = bk.Counter(message="Toks", speed_unit="tok/s", speed=1.0)
    bar = sents | toks
    bar.show()
    for i in range(1010):
        # do work
        time.sleep(0.013)
        sents += 1
        toks += 1 + random.randrange(5)
    bar.done()
    
  • Use "no tty" mode to, e.g., output to log files:

    bar = bk.ProgressBar(total=401, message="Sents", speed=1.0, interval=1.0, no_tty=True)
    bar.show()
    for i in range(401):
        time.sleep(0.013)
        bar += 1
    bar.done()
    

    no_tty achieves two things:

    • Change the delimiter from \r to \n to avoid wonky looking output in your log files.
    • Change the default interval to a minute to avoid overwhelming logs (in the example above, we set the interval ourselves explicitly).

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc