rafguns / doidownloader

You give it DOIs, it gives you the article PDFs
MIT License
0 stars 0 forks source link

Use rich for progress bars #4

Closed rafguns closed 1 year ago

rafguns commented 1 year ago

Much as I like tqdm, it's a pain to set up in Jupyter. Seems like rich makes this easier.

rafguns commented 1 year ago

I use a progress bar in two different functions (save_metadata and save_fulltext). But when I define a custom progress bar at the top of the file, the second time I use it, it also shows the output of the first. So I guess I should define afunction that returns a progress bar the way I like it? Maybe something like this:

def track(description="Working..."):
    progress = Progress(
        TextColumn("[progress.description]{task.description}"),
        BarColumn(),
        MofNCompleteColumn(),
        TimeRemainingColumn(),
    )
    return progress.track(description=description)

EDIT: OK, that doesn't really work as written but the general idea is good. I think I have a working version now.