ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
python.ProgressBar.progressBar Class Reference
Collaboration diagram for python.ProgressBar.progressBar:

Public Member Functions

def __init__ (self, minValue=0, maxValue=10, totalWidth=12, prefix="", suffix="")
 
def update (self, newAmount=0)
 
def done (self)
 
def __str__ (self)
 

Public Attributes

 progBar
 
 min
 
 max
 
 span
 
 amount
 
 nextUpdate
 
 prefix
 
 suffix
 
 width
 

Detailed Description

Definition at line 5 of file ProgressBar.py.

Constructor & Destructor Documentation

◆ __init__()

def python.ProgressBar.progressBar.__init__ (   self,
  minValue = 0,
  maxValue = 10,
  totalWidth = 12,
  prefix = "",
  suffix = "" 
)

Definition at line 6 of file ProgressBar.py.

6  def __init__(self, minValue = 0, maxValue = 10, totalWidth=12, prefix="", suffix=""):
7  self.progBar = "[]" # This holds the progress bar string
8  self.min = minValue
9  self.max = maxValue
10  self.span = maxValue - minValue
11  self.amount = 0 # When amount == max, we are 100% done
12  self.nextUpdate = minValue+float(self.span/100.0)
13  if len(prefix):
14  self.prefix=prefix+" ["
15  else:
16  self.prefix="["
17  if len(suffix):
18  self.suffix="] " + suffix
19  else:
20  self.suffix="]"
21  self.width = totalWidth - len(self.prefix) - len(self.suffix)
22  self.update(0) # Build progress bar string
23 

Member Function Documentation

◆ __str__()

def python.ProgressBar.progressBar.__str__ (   self)

Definition at line 64 of file ProgressBar.py.

64  def __str__(self):
65  return str(self.progBar)

◆ done()

def python.ProgressBar.progressBar.done (   self)

Definition at line 59 of file ProgressBar.py.

59  def done(self):
60  self.update(self.max)
61  sys.stdout.write('\r' + self.progBar + '\n')
62  sys.stdout.flush()# force updating of screen
63 

◆ update()

def python.ProgressBar.progressBar.update (   self,
  newAmount = 0 
)

Definition at line 24 of file ProgressBar.py.

24  def update(self, newAmount = 0):
25  if newAmount < self.min:
26  newAmount = self.min
27  if newAmount > self.max:
28  newAmount = self.max
29 
30  #=== only continue if something new to draw
31  if newAmount < self.nextUpdate and newAmount<self.max :
32  return
33  self.nextUpdate = self.nextUpdate+float(self.span/100.0)
34  self.amount = newAmount
35 
36  # Figure out the new percent done, round to an integer
37  diffFromMin = float(self.amount - self.min)
38  percentDone = (diffFromMin / float(self.span)) * 100.0 if self.span>0 else 100.
39  percentDone = round(percentDone)
40  percentDone = int(percentDone)
41 
42  # Figure out how many hash bars the percentage should be
43  numHashes = (percentDone / 100.0) * self.width
44  numHashes = int(round(numHashes))
45 
46  # build a progress bar with hashes and spaces
47  self.progBar = self.prefix + '#'*numHashes + ' '*(self.width-numHashes) + self.suffix
48 
49  # figure out where to put the percentage, roughly centered
50  percentPlace = (len(self.progBar) // 2) - len(str(percentDone))
51  percentString = str(percentDone) + "%"
52 
53  # slice the percentage into the bar
54  self.progBar = self.progBar[0:percentPlace] + percentString + self.progBar[percentPlace+len(percentString):]
55 
56  sys.stdout.write('\r' + self.progBar)
57  sys.stdout.flush()# force updating of screen
58 

Member Data Documentation

◆ amount

python.ProgressBar.progressBar.amount

Definition at line 11 of file ProgressBar.py.

◆ max

python.ProgressBar.progressBar.max

Definition at line 9 of file ProgressBar.py.

◆ min

python.ProgressBar.progressBar.min

Definition at line 8 of file ProgressBar.py.

◆ nextUpdate

python.ProgressBar.progressBar.nextUpdate

Definition at line 12 of file ProgressBar.py.

◆ prefix

python.ProgressBar.progressBar.prefix

Definition at line 14 of file ProgressBar.py.

◆ progBar

python.ProgressBar.progressBar.progBar

Definition at line 7 of file ProgressBar.py.

◆ span

python.ProgressBar.progressBar.span

Definition at line 10 of file ProgressBar.py.

◆ suffix

python.ProgressBar.progressBar.suffix

Definition at line 18 of file ProgressBar.py.

◆ width

python.ProgressBar.progressBar.width

Definition at line 21 of file ProgressBar.py.


The documentation for this class was generated from the following file:
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
str
Definition: BTagTrackIpAccessor.cxx:11
WriteBchToCool.update
update
Definition: WriteBchToCool.py:67
readCCLHist.float
float
Definition: readCCLHist.py:83