MCPcopy
hub / github.com/Textualize/rich / wrap_file

Function wrap_file

rich/progress.py:306–368  ·  view source on GitHub ↗

Read bytes from a file while tracking progress. Args: file (Union[str, PathLike[str], BinaryIO]): The path to the file to read, or a file-like object in binary mode. total (int): Total number of bytes to read. description (str, optional): Description of task show next to

(
    file: BinaryIO,
    total: int,
    *,
    description: str = "Reading...",
    auto_refresh: bool = True,
    console: Optional[Console] = None,
    transient: bool = False,
    get_time: Optional[Callable[[], float]] = None,
    refresh_per_second: float = 10,
    style: StyleType = "bar.back",
    complete_style: StyleType = "bar.complete",
    finished_style: StyleType = "bar.finished",
    pulse_style: StyleType = "bar.pulse",
    disable: bool = False,
)

Source from the content-addressed store, hash-verified

304
305
306def wrap_file(
307 file: BinaryIO,
308 total: int,
309 *,
310 description: str = "Reading...",
311 auto_refresh: bool = True,
312 console: Optional[Console] = None,
313 transient: bool = False,
314 get_time: Optional[Callable[[], float]] = None,
315 refresh_per_second: float = 10,
316 style: StyleType = "bar.back",
317 complete_style: StyleType = "bar.complete",
318 finished_style: StyleType = "bar.finished",
319 pulse_style: StyleType = "bar.pulse",
320 disable: bool = False,
321) -> ContextManager[BinaryIO]:
322 """Read bytes from a file while tracking progress.
323
324 Args:
325 file (Union[str, PathLike[str], BinaryIO]): The path to the file to read, or a file-like object in binary mode.
326 total (int): Total number of bytes to read.
327 description (str, optional): Description of task show next to progress bar. Defaults to "Reading".
328 auto_refresh (bool, optional): Automatic refresh, disable to force a refresh after each iteration. Default is True.
329 transient: (bool, optional): Clear the progress on exit. Defaults to False.
330 console (Console, optional): Console to write to. Default creates internal Console instance.
331 refresh_per_second (float): Number of times per second to refresh the progress information. Defaults to 10.
332 style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
333 complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
334 finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
335 pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
336 disable (bool, optional): Disable display of progress.
337 Returns:
338 ContextManager[BinaryIO]: A context manager yielding a progress reader.
339
340 """
341
342 columns: List["ProgressColumn"] = (
343 [TextColumn("[progress.description]{task.description}")] if description else []
344 )
345 columns.extend(
346 (
347 BarColumn(
348 style=style,
349 complete_style=complete_style,
350 finished_style=finished_style,
351 pulse_style=pulse_style,
352 ),
353 DownloadColumn(),
354 TimeRemainingColumn(),
355 )
356 )
357 progress = Progress(
358 *columns,
359 auto_refresh=auto_refresh,
360 console=console,
361 transient=transient,
362 get_time=get_time,
363 refresh_per_second=refresh_per_second or 10,

Callers 1

file_progress.pyFile · 0.90

Calls 8

wrap_fileMethod · 0.95
TextColumnClass · 0.85
BarColumnClass · 0.85
DownloadColumnClass · 0.85
TimeRemainingColumnClass · 0.85
ProgressClass · 0.85
_ReadContextClass · 0.85
extendMethod · 0.45

Tested by

no test coverage detected