yr.spinner
spinner(
message: str = 'Working',
glyph: str = 'run',
colour: NamedColour = 'orange',
end_message: str = 'Done',
end_glyph: str = 'check',
end_colour: NamedColour = 'green',
) → SpinnerStreamShow a configurable spinner while a block of work runs.
The spinner may change its message, glyph, and colour while active. On successful exit it resolves to the configured completion appearance; on exceptional exit it uses the fixed failure appearance.
Parameters
message
type: str = 'Working'
Initial message shown alongside the spinner.
glyph
type: str = 'run'
Initial registered glyph name.
colour
type: NamedColour = 'orange'
Initial named colour.
end_message
type: str = 'Done'
Message shown after successful completion.
end_glyph
type: str = 'check'
Registered glyph shown after successful completion.
end_colour
type: NamedColour = 'green'
Named colour shown after successful completion.
Returns
type: SpinnerStream
A SpinnerStream context manager.
Examples
Show progress while a longer operation runs:
import yera as yr
with yr.spinner(
"Searching the recipe book",
end_message="Recipes found",
) as progress:
recipes = find_recipes()
progress.update("Sorting by preparation time")
recipes.sort(key=lambda recipe: recipe.preparation_time)