cereja

Cereja is a bundle of useful functions we don't want to rewrite and .. just pure fun!

View the Project on GitHub cereja-project/cereja

Display Package

⏳ Progress

See the progress of an iteration in a simple way

Simple usage

import cereja as cj
import time

my_iterable = ['Cereja', 'is', 'very', 'easy']


for i in cj.Progress.prog(my_iterable):
    print(f"current: {i}")
    time.sleep(2)

# Output on terminal ...

# 🍒 Sys[out] » current: Cereja 
# 🍒 Sys[out] » current: is 
# 🍒 Cereja Progress » [▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▱▱▱▱▱▱▱▱▱▱▱▱▱▱] - 50.00% - 🕢 00:00:02 estimated
Custom Display
import cereja as cj
import time

progress = cj.Progress("My Progress")
print(progress)

print(progress[0])
print(progress[1])
print(progress[2])


class MyCustomState(cj.display.State):
    def display(self, current_value, max_value, *args, **kwargs):
        return f'{current_value} -> {max_value}'

    def done(self, *args, **kwargs):
        return f'FINISHED'


progress[0] = MyCustomState

for i in progress(range(1, 500)):
    time.sleep(1 / i)
With Statement
import cereja as cj
import time

with cj.Progress("My Progress") as prog:
    time.sleep(5)
    for i in prog(range(1, 500)):
        time.sleep(1 / i)
    for i in prog(range(1, 500)):
        time.sleep(1 / i)