progressindicator package¶
Submodules¶
progressindicator.base module¶
This module contains the BaseExtension and BaseProvider class.
-
class
progressindicator.base.
BaseExtension
(requirements, update_interval=None)[source]¶ Bases:
object
-
get_requirements
()[source]¶ Get the requirements of the extension.
Returns: list of tags required by the extension. Return type: array_like
-
set_value
(value)[source]¶ This method sets the content which is to be printed to console.
Parameters: value (str) – Value to be set.
-
get_value
()[source]¶ Get the current value to be printed to console.
Returns: value set by set_value Return type: str
-
on_begin
(params)[source]¶ Override this method to customize the initial look of the extension.
By default, the appropriate after-validation method is called.
Parameters: params (array_like) – Values of all keys specified in the requirements of the extension.
-
on_update
(params)[source]¶ Override this method to set the look of the extension at each update.
This method is called at each update. It is recommended to override the higher level functions on_validated and on_invalidated instead of this method.
Parameters: params (array_like) – Values of all keys specified in the requirements of the extension.
-
on_end
(params)[source]¶ Override this method to customize the final look of the extension.
By default, the appropriate after-validation method is called.
Parameters: params (array_like) – Values of all keys specified in the requirements of the extension.
-
on_validated
(params)[source]¶ Override this method to set the look of the extension at each update.
This method is only called during an update if value of all tags required by the extension are valid.
Parameters: params (array_like) – Values of all keys specified in the requirements of the extension.
-
on_invalidated
(params)[source]¶ Override this method to set the look of the extension at each update.
This method is only called during an update if value for atleast one tag required by the extension is invalid.
Parameters: params (array_like) – Values of all keys specified in the requirements of the extension.
-
-
class
progressindicator.base.
BaseProvider
(tag, requirements)[source]¶ Bases:
object
-
get_requirements
()[source]¶ Get the requirements of the extension.
Returns: requirements of the extension. Return type: array_like
-
set_value
(value)[source]¶ This method sets the value of the tag provided by the provider.
Parameters: value (str) – Value to be set.
-
get_value
()[source]¶ Get the current value of the provider’s tag.
Returns: value set by set_value Return type: str
-
on_begin
(params)[source]¶ Override this method to set the initial value for the provider.
By default, the appropriate after-validation method is called.
Parameters: params (array_like) – Values of all keys specified in the requirements of the extension.
-
on_update
(params)[source]¶ Override this method to calculate the value for the provider at each publish.
This method is called on every publish. It is recommended to override the higher level functions on_validated and on_invalidated instead of this method.
Parameters: params (array_like) – Values of all tags specified in the requirements of the extension.
-
on_end
(params)[source]¶ Override this method to calculate the final value for the provider.
By default, the appropriate after-validation method is called.
Parameters: params (array_like) – Values of all tags specified in the requirements of the extension.
-
on_validated
(params)[source]¶ Override this method to calculate the value for the provider at each publish.
This method is only called during an update if value of all keys in requirements are valid.
Parameters: params (array_like) – Values of all keys specified in the requirements of the extension.
-
on_invalidated
(params)[source]¶ Override this method to calculate the value for the provider at each publish.
This method is only called during an update if value for atleast one key in requirements is invalid.
Parameters: params (array_like) – Values of all keys specified in the requirements of the extension.
-
progressindicator.core module¶
-
class
progressindicator.core.
ProgressIndicator
(components, min_value=0, max_value=100, stream=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>, max_update_interval=0.5)[source]¶ Bases:
object
Utility Class to display Progress Bars in console.
Parameters: - components (array_like) – pass
- min_value (float, optional) – Minimum value of the progress. Default is 0.
- max_value (float, optional) – Maximum value of the progress. Default is 100.
- max_update_interval (float) – Maximum time interval between two updates of the Progress Indicator. Default is 0.50s.
-
clear_on_task_completion
¶ bool – Whether Progress Bar is cleared on calling end.
-
min_value
¶ int, float – Minimum value of the progress.
-
max_value
¶ int, float – Maximum value of the progress
-
max_update_interval
¶ float – Maximum interval in seconds between succesive updates
-
seperator
¶ str – String used to join output of components.(Default ‘ ‘)
-
components
¶ list – List of components used to build the progress bar.
-
begin
()[source]¶ Performs initial tasks prior to printing progress bar.
It is recommended to perform all customization to the ProgressIndicator instance before calling this method. This method should be called for initializing Progress Bar. If not called, first call to publish() will automatically call this method.
-
end
()[source]¶ Performs clean up tasks after printing Progress Bar.
This method should always be called after task is complete. This method forces the progress Bar to show progress to 100 percent. After calling this method publish() can no longer be called. This method clears the Progress Bar from the console if clear_on_task_completion is True. The console should support printing carriage returns.
-
next
()¶
-
register_provider
(provider)[source]¶ Any custom providers needed for an extension should be registered using this method.
Parameters: provider (BaseProvider) – An instance of the Custom BaseProvider child class.
-
deregister_provider
(tag)[source]¶ All providers can be deregistered using this method.
Parameters: tag (str) – Tag of the Provider you wish to remove. Note
For optimization purposes, You don’t need to deregister providers if they are not needed as Providers which are not required are never executed.
progressindicator.extensions module¶
This module contains the Built-in Extensions for ProgressIndicator class.
-
class
progressindicator.extensions.
Bar
(length=60, begin_entity='[', filler_entity='#', empty_entity=' ', end_entity=']')[source]¶ Extension to display Progress bar in console.
Parameters: - length (int, optional) – Number of entities in the Bar (Default 60)
- begin_entity (str, optional) – Symbol to indicate start of the Bar (Default ‘[‘)
- filler_entity (str, optional) – Symbol which is used to show completed part of the Bar (Default ‘#’)
- empty_entity (str, optional) – Symbol which is used to show incomplete part of the Bar (Default ‘ ‘)
- end_entity (str, optional) – Symbol to indicate end of the Bar (Default ‘]’)
-
class
progressindicator.extensions.
BouncingBar
(length=60, begin_entity='[', filler_entity='*', empty_entity=' ', end_entity=']', velocity=100)[source]¶ This Extension displays a visual cue for a task with indeterminate progress.
Parameters: - length (int, optional) – Number of entities in the Bar (Default 60)
- begin_entity (str, optional) – Symbol to indicate start of the Bar (Default ‘[‘)
- filler_entity (str, optional) – Symbol which is used to show completed part of the Bar (Default ‘*’)
- empty_entity (str, optional) – Symbol which is used to show incomplete part of the Bar (Default ‘ ‘)
- end_entity (str, optional) – Symbol to indicate end of the Bar (Default ‘]’)
- velocity (int, optional) – Speed of the filler (Default 200)
-
class
progressindicator.extensions.
Alternator
(char_iter)[source]¶ This Extension displays items from a List in a sequential order in a loop after every a fixed time interval.
Parameters: char_iter (iterable of str) – The set of string through which the extension should loop.
-
class
progressindicator.extensions.
Spinner
[source]¶ This Extension displays a visual cue for a task with indeterminate progress. It displays a rotating marker to indicate progress of a task.
-
class
progressindicator.extensions.
Loader
(char='.', n=3)[source]¶ This Extension displays a visual cue for a task with indeterminate progress.
Parameters: - char (str) – The character which is to be repeated.
- n (int) – The maximum number character which should be displayed.
-
class
progressindicator.extensions.
Timer
[source]¶ This Extension provides total time since the task was started.
-
class
progressindicator.extensions.
ETA
[source]¶ This Extension displays the expected time left for the task to be completed.
-
class
progressindicator.extensions.
ETA1
[source]¶ This Extension displays an alternate expected time left for the task to be completed.
progressindicator.providers module¶
-
class
progressindicator.providers.
ETAProvider
[source]¶ Default Provider for an estimate of the time remaining for the completion of the task underway. The tag for this provider is eta. This provider is used by the built-in ETA extension.
progressindicator.tags module¶
This module contains all the built-in tags for progressindicator package.
Refers to value passed via publish
Refers to max_value attribute of the Progress bar
Refers to min_value attribute of the Progress bar
Refers to the time at which begin was called
Refers to the time at which end was called
Refers to the number of calls that have been made to publish
Refers to how much of the task has been completed in percentage
Refers to the time(sec) since begin was called
Refers to the time(sec) since publish was called
Refers to the time at which Progress bar was last updated on screen.
Refers to the time(sec) since the Progress bar was last updated on screen.
Refers to the expected time(s) the task would need to complete
Refers to an alternate implementation of expected time(s) the task would need to complete
Refers to current rate of calls to publish