Cat
Public Member Functions | Public Attributes | Private Member Functions | Static Private Attributes | List of all members
progressbar.ProgressBar Class Reference
Inheritance diagram for progressbar.ProgressBar:
progressbar.AnimatedProgressBar

Public Member Functions

def __init__ (self, process=" ", start=0, end=10, width=12, fill='=', blank='.', format='running %(process) s [%(fill) s%(blank) s] %(progress) s%%', incremental=True)
 
def __add__ (self, increment)
 
def __str__ (self)
 
def set (self, value)
 
def reset (self)
 

Public Attributes

 start
 
 end
 
 width
 
 fill
 
 blank
 
 format
 
 incremental
 
 step
 
 process
 
 progress
 

Private Member Functions

def _get_progress (self, increment)
 

Static Private Attributes

def __repr__ = __str__
 

Detailed Description

ProgressBar class holds the options of the progress bar.
The options are:
    start   State from which start the progress. For example, if start is
            5 and the end is 10, the progress of this state is 50%
    end     State in which the progress has terminated.
    width   --
    fill    String to use for "filled" used to represent the progress
    blank   String to use for "filled" used to represent remaining space.
    format  Format
    incremental

Definition at line 4 of file progressbar.py.

Constructor & Destructor Documentation

◆ __init__()

def progressbar.ProgressBar.__init__ (   self,
  process = "     ",
  start = 0,
  end = 10,
  width = 12,
  fill = '=',
  blank = '.',
  format = 'running %(process)s [%(fill)s%(blank)s] %(progress)s%%',
  incremental = True 
)

Definition at line 16 of file progressbar.py.

16  def __init__(self, process=" ", start=0, end=10, width=12, fill='=', blank='.', format='running %(process)s [%(fill)s%(blank)s] %(progress)s%%', incremental=True): super(ProgressBar, self).__init__()
17 
18  self.start = start
19  self.end = end
20  self.width = width
21  self.fill = fill
22  self.blank = blank
23  self.format = format
24  self.incremental = incremental
25  self.step = 100 / float(width) #fix
26  self.process = process
27  self.reset()
28 
29 
def __init__(self, dict)
Definition: wrapper.py:56

Member Function Documentation

◆ __add__()

def progressbar.ProgressBar.__add__ (   self,
  increment 
)

Definition at line 30 of file progressbar.py.

References progressbar.ProgressBar._get_progress(), and progressbar.ProgressBar.progress.

30  def __add__(self, increment):
31  increment = self._get_progress(increment)
32  if 100 > self.progress + increment:
33  self.progress += increment
34  else:
35  self.progress = 100
36  return self
37 

◆ __str__()

def progressbar.ProgressBar.__str__ (   self)

Definition at line 38 of file progressbar.py.

References progressbar.ProgressBar.blank, progressbar.ProgressBar.fill, progressbar.ProgressBar.format, progressbar.ProgressBar.process, progressbar.ProgressBar.progress, progressbar.ProgressBar.step, and progressbar.ProgressBar.width.

38  def __str__(self):
39  progressed = int(self.progress / self.step) #fix
40  fill = progressed * self.fill
41  proc = self.process
42  blank = (self.width - progressed) * self.blank
43  return self.format % {'process': proc, 'fill': fill, 'blank': blank, 'progress': int(self.progress)}
44 

◆ _get_progress()

def progressbar.ProgressBar._get_progress (   self,
  increment 
)
private

Definition at line 47 of file progressbar.py.

References progressbar.ProgressBar.end.

Referenced by progressbar.ProgressBar.__add__(), progressbar.ProgressBar.reset(), and progressbar.ProgressBar.set().

47  def _get_progress(self, increment):
48  return float(increment * 100) / self.end
49 

◆ reset()

def progressbar.ProgressBar.reset (   self)
Resets the current progress to the start point

Definition at line 58 of file progressbar.py.

References progressbar.ProgressBar._get_progress(), progressbar.ProgressBar.progress, and progressbar.ProgressBar.start.

58  def reset(self):
59  """Resets the current progress to the start point"""
60  self.progress = self._get_progress(self.start)
61  return self
62 
63 
def reset(path='')
Definition: shell.py:212

◆ set()

def progressbar.ProgressBar.set (   self,
  value 
)

Definition at line 50 of file progressbar.py.

References progressbar.ProgressBar._get_progress(), and progressbar.ProgressBar.progress.

50  def set(self, value):
51  value = self._get_progress(value)
52  if 100 > value:
53  self.progress = value
54  else:
55  self.progress = 100
56  return self
57 

Member Data Documentation

◆ __repr__

def progressbar.ProgressBar.__repr__ = __str__
staticprivate

Definition at line 45 of file progressbar.py.

◆ blank

progressbar.ProgressBar.blank

Definition at line 23 of file progressbar.py.

Referenced by progressbar.ProgressBar.__str__().

◆ end

progressbar.ProgressBar.end

Definition at line 20 of file progressbar.py.

Referenced by progressbar.ProgressBar._get_progress().

◆ fill

progressbar.ProgressBar.fill

Definition at line 22 of file progressbar.py.

Referenced by progressbar.ProgressBar.__str__().

◆ format

progressbar.ProgressBar.format

Definition at line 24 of file progressbar.py.

Referenced by progressbar.ProgressBar.__str__().

◆ incremental

progressbar.ProgressBar.incremental

Definition at line 25 of file progressbar.py.

◆ process

progressbar.ProgressBar.process

Definition at line 27 of file progressbar.py.

Referenced by progressbar.ProgressBar.__str__().

◆ progress

◆ start

progressbar.ProgressBar.start

Definition at line 19 of file progressbar.py.

Referenced by progressbar.ProgressBar.reset().

◆ step

progressbar.ProgressBar.step

Definition at line 26 of file progressbar.py.

Referenced by progressbar.ProgressBar.__str__().

◆ width

progressbar.ProgressBar.width

Definition at line 21 of file progressbar.py.

Referenced by progressbar.ProgressBar.__str__().


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