mirror of
https://github.com/Textualize/rich.git
synced 2025-08-04 01:58:24 +00:00
docs update
This commit is contained in:
parent
8a9e9a2022
commit
b6a83c2dce
1 changed files with 2 additions and 12 deletions
|
@ -26,16 +26,6 @@ For basic usage call the :func:`~rich.progress.track` function, which accepts a
|
|||
for n in track(range(n), description="Processing..."):
|
||||
do_work(n)
|
||||
|
||||
|
||||
To get a progress bar while reading from a file, you may consider using the :func:`~rich.progress.read` function, which accepts a path, or a *file-like* object. It will return a *file-like* object in *binary mode* that will update the progress information as it's being read from. Here's an example, tracking the progresses made by :func:`json.load` to load a file::
|
||||
|
||||
import json
|
||||
from rich.progress import read
|
||||
|
||||
with read("data.json", description="Loading data...") as f:
|
||||
data = json.load(f)
|
||||
|
||||
|
||||
Advanced usage
|
||||
--------------
|
||||
|
||||
|
@ -212,9 +202,9 @@ If the :class:`~rich.progress.Progress` class doesn't offer exactly what you nee
|
|||
Reading from a file
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Rich provides an easy way to generate a progress bar for reading a file. If you call :func:`~rich.progress.open` it will return a context manager which displays a progress bar while you read. This is particularly useful when you can't easily modify the code that does the reading.
|
||||
Rich provides an easy way to generate a progress bar while reading a file. If you call :func:`~rich.progress.open` it will return a context manager which displays a progress bar while you read. This is particularly useful when you can't easily modify the code that does the reading.
|
||||
|
||||
The following example shows how we might show progress for reading a JSON file::
|
||||
The following example demonstrates how we might show progress when reading a JSON file::
|
||||
|
||||
import json
|
||||
import rich.progress
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue