sammo.compactbars

sammo.compactbars#

Provides a way of displaying multiple progress bars in a single line. Works in both interactive and non-interactive environments.

Module Contents#

Classes#

CompactProgressBars

A class that represents a set of progress bars drawn next to each in a single line.

SubProgressBar

A class that represents an individual progress bar.

API#

class sammo.compactbars.CompactProgressBars(width: int | None = None, refresh_interval: float = 1 / 50)#

A class that represents a set of progress bars drawn next to each in a single line.

Parameters:
  • width – The total width of the progress bar layout in characters.

  • refresh_interval – The minimum time interval between display refreshes.

Initialization

get(id: str, total: int | None = None, position: int | None = None, display_name: str | None = None, **kwargs) sammo.compactbars.SubProgressBar#

Gets existing or creates a new progress bar given an id.

Parameters:
  • id – The id of the progress bar for later reference.

  • total – Number of increments.

  • position – Truncate existing bars beyond index and insert this one at the position.

  • display_name – The name to display for the progress bar. Defaults to id.

  • **kwargs –

    Additional arguments to pass to the SubProgressbar constructor.

:return New bar if it doesn’t exist, otherwise a reference to the existing one.

finalize() None#

Finishes the line and moves the cursor to the next line.

class sammo.compactbars.SubProgressBar(total: int, parent: sammo.compactbars.CompactProgressBars, moving_avg_size: int = 10, width: int = 100, prefix: str = '', show_rate: bool = True, show_time: bool = True, ascii: str = 'auto')#

A class that represents an individual progress bar.

Parameters:
  • total – The total number of items to process.

  • parent – The parent progress bar.

  • moving_avg_size – The size of the moving average window for calculating the rate.

  • width – The width of the progress bar in characters.

  • prefix – The prefix to display before the progress bar.

  • show_rate – Whether to show the rate of progress.

  • show_time – Whether to show the elapsed time and ETA.

  • ascii – Whether to use ASCII (or UTF-8) characters for the progress bar. If β€œauto”, uses ASCII if pdb is imported.

Initialization

phases = None#
property total#
property done#
property elapsed_long#
property elapsed#
property phase#
property barwidth#
property rate#
property eta#
update(*args, **kwargs)#

Increases the number of completed tasks by one for the progress bar.