Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
The simplest no-nonsense progress bar for python.
lowbar is a blazing fast module with zero dependencies for displaying a progress bar in the terminal. It has a low number of features and a simple codebase, hence the name lowbar.
\n
and carriage return \r
.Install the latest stable release:
pip install lowbar
Or the development version:
pip install git+https://github.com/AnnikaV9/lowbar
Once you have lowbar installed, you can import it like any other module:
from lowbar import lowbar
And initialize the bar:
bar = lowbar()
To make the bar visible and set at 0%:
bar.new()
After completing some tasks, we can increase the bar's completion percentage:
bar.add(20)
If we have a known number of tasks, lowbar can automatically calculate the percentage for us:
bar.next(n_tasks)
[!NOTE] If you set the number of tasks when initializing lowbar with
lowbar(n_tasks)
, you don't need to passn_tasks
tonext()
.
We can also set the completion percentage instead of adding to it:
bar.update(50)
Using print()
or other similar functions will push the bar up, which doesn't look nice. To log messages without affecting the bar:
bar.log("Hello World!")
And finally, to clear the bar completely:
bar.clear()
Here's an example usage of the bar:
bar = lowbar(10)
bar.new()
for i in range(10):
time.sleep(0.5) # task
bar.log(f"Task {i+1} completed")
bar.next()
bar.clear()
print("Tasks complete!")
You don't even need a loop:
bar.new()
time.sleep(0.5) # task
bar.add(10)
time.sleep(0.5) # task
bar.add(10)
time.sleep(0.5) # task
bar.update(100)
bar.clear()
print("Tasks complete!")
The bar can also be used with a context manager. It will automatically run new()
at the start and clear()
when exiting:
with lowbar(2) as bar:
time.sleep(0.5) # task
bar.next()
time.sleep(0.5) # task
bar.next()
print("Tasks complete!")
To make things simpler, you can wrap lowbar around range()
and turn it into an iterable. It will automatically calculate how much to increase the percentage by every loop:
for i in lowbar(range(100)):
time.sleep(0.5) # task
Pass an integer and lowbar will convert it into a range object for you:
for i in lowbar(100):
time.sleep(0.5) # task
[!NOTE] You can't use
log()
when using lowbar as an iterable.
You can also change the load fill and blank fill chars:
bar = lowbar(load_fill="O", blank_fill=".")
Or add a description text to the left side of the bar:
bar = lowbar(desc="Downloading...")
[!NOTE] If the console is too small to accommodate both the bar and the description text, the text will be hidden.
See the reference for more details.
All contributions are welcome!
If you wish to report a bug or suggest a feature, open an issue.
You can also make a pull request directly if you already have the fix for a bug.
See CONTRIBUTING.md for guidelines to follow.
Contributors are listed in CONTRIBUTORS.md.
This project is licensed under the MIT License.
FAQs
The simplest no-nonsense progress bar for python.
We found that lowbar demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.