Document ProcessingProgressDisplay
This commit is contained in:
parent
6f7a7a6d79
commit
625491d242
1 changed files with 16 additions and 0 deletions
|
@ -348,11 +348,17 @@ class Processor():
|
||||||
|
|
||||||
|
|
||||||
class ProcessingProgressDisplay():
|
class ProcessingProgressDisplay():
|
||||||
|
"""Display processing progress periodically on stdout."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
processing_elements: List[str],
|
processing_elements: List[str],
|
||||||
) -> None:
|
) -> None:
|
||||||
|
"""
|
||||||
|
Constructor.
|
||||||
|
|
||||||
|
:param processing_elements: the list of elements doing processing
|
||||||
|
"""
|
||||||
self.__info_string = '[' + ', '.join(processing_elements) + ']'
|
self.__info_string = '[' + ', '.join(processing_elements) + ']'
|
||||||
self.__progress_count = 0
|
self.__progress_count = 0
|
||||||
self.__total_work = 0
|
self.__total_work = 0
|
||||||
|
@ -362,6 +368,11 @@ class ProcessingProgressDisplay():
|
||||||
self,
|
self,
|
||||||
total: int,
|
total: int,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
"""
|
||||||
|
Set the total units of work.
|
||||||
|
|
||||||
|
:param total: the total number of units of work to do
|
||||||
|
"""
|
||||||
self.__total_work = total
|
self.__total_work = total
|
||||||
self.__work_display_period = int(self.__total_work / 100.0)
|
self.__work_display_period = int(self.__total_work / 100.0)
|
||||||
|
|
||||||
|
@ -369,6 +380,11 @@ class ProcessingProgressDisplay():
|
||||||
self,
|
self,
|
||||||
increment: int = 1,
|
increment: int = 1,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
"""
|
||||||
|
Increment the amount of work done.
|
||||||
|
|
||||||
|
:param increment: the number of units of work to add to the total
|
||||||
|
"""
|
||||||
self.__progress_count += increment
|
self.__progress_count += increment
|
||||||
if self.__progress_count % self.__work_display_period == 0:
|
if self.__progress_count % self.__work_display_period == 0:
|
||||||
percentage = 100.0 * (float(self.__progress_count) / float(self.__total_work))
|
percentage = 100.0 * (float(self.__progress_count) / float(self.__total_work))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue