Public Member Functions | Public Attributes | Private Attributes | List of all members
cache_state.ProgressBar Class Reference
Inheritance diagram for cache_state.ProgressBar:

Public Member Functions

def __init__ (self, total, announce_threshold=50)
 
def Update (self, n)
 

Public Attributes

 total
 
 announce
 

Private Attributes

 _total_div10
 
 _last_announce_decile
 

Detailed Description

Definition at line 35 of file cache_state.py.

Constructor & Destructor Documentation

def cache_state.ProgressBar.__init__ (   self,
  total,
  announce_threshold = 50 
)

Definition at line 36 of file cache_state.py.

36  def __init__(self, total, announce_threshold=50):
37  self.total = total
38  self._total_div10 = total // 10
39 
40  self.announce = total >= announce_threshold
42 
43  self.Update(0)
44 
def __init__(self, total, announce_threshold=50)
Definition: cache_state.py:36

Member Function Documentation

def cache_state.ProgressBar.Update (   self,
  n 
)

Definition at line 45 of file cache_state.py.

45  def Update(self, n):
46  current_decile = None
47  if self.total > 10:
48  current_decile = n // self._total_div10
49  if self.announce:
50  if current_decile is None:
51  print( " %d" % n, end=" " )
52  if (current_decile > self._last_announce_decile or n == self.total): # always want to announce 100%
53  curr_perc = int(n / self.total * 100)
54  print( " %d%%" % curr_perc, end=" " )
55 
56  self._last_announce_decile = n // self._total_div10
57 
58  sys.stdout.flush()
59 

Member Data Documentation

cache_state.ProgressBar._last_announce_decile
private

Definition at line 41 of file cache_state.py.

cache_state.ProgressBar._total_div10
private

Definition at line 38 of file cache_state.py.

cache_state.ProgressBar.announce

Definition at line 40 of file cache_state.py.

cache_state.ProgressBar.total

Definition at line 37 of file cache_state.py.


The documentation for this class was generated from the following file: