summaryrefslogtreecommitdiffstats
path: root/lldb/third_party/Python/module/progress
diff options
context:
space:
mode:
authorKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
committerKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
commitb9c1b51e45b845debb76d8658edabca70ca56079 (patch)
treedfcb5a13ef2b014202340f47036da383eaee74aa /lldb/third_party/Python/module/progress
parentd5aa73376966339caad04013510626ec2e42c760 (diff)
downloadbcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz
bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
Diffstat (limited to 'lldb/third_party/Python/module/progress')
-rw-r--r--lldb/third_party/Python/module/progress/progress.py96
1 files changed, 63 insertions, 33 deletions
diff --git a/lldb/third_party/Python/module/progress/progress.py b/lldb/third_party/Python/module/progress/progress.py
index 734627d4b16..3397cf04301 100644
--- a/lldb/third_party/Python/module/progress/progress.py
+++ b/lldb/third_party/Python/module/progress/progress.py
@@ -8,10 +8,11 @@ import six
import sys
import time
+
class ProgressBar(object):
"""ProgressBar class holds the options of the progress bar.
The options are:
- start State from which start the progress. For example, if start is
+ 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 --
@@ -23,15 +24,15 @@ class ProgressBar(object):
light_block = six.unichr(0x2591).encode("utf-8")
solid_block = six.unichr(0x2588).encode("utf-8")
solid_right_arrow = six.unichr(0x25BA).encode("utf-8")
-
- def __init__(self,
- start=0,
- end=10,
- width=12,
- fill=six.unichr(0x25C9).encode("utf-8"),
- blank=six.unichr(0x25CC).encode("utf-8"),
- marker=six.unichr(0x25CE).encode("utf-8"),
- format='[%(fill)s%(marker)s%(blank)s] %(progress)s%%',
+
+ def __init__(self,
+ start=0,
+ end=10,
+ width=12,
+ fill=six.unichr(0x25C9).encode("utf-8"),
+ blank=six.unichr(0x25CC).encode("utf-8"),
+ marker=six.unichr(0x25CE).encode("utf-8"),
+ format='[%(fill)s%(marker)s%(blank)s] %(progress)s%%',
incremental=True):
super(ProgressBar, self).__init__()
@@ -43,7 +44,7 @@ class ProgressBar(object):
self.marker = marker
self.format = format
self.incremental = incremental
- self.step = 100 / float(width) #fix
+ self.step = 100 / float(width) # fix
self.reset()
def __add__(self, increment):
@@ -59,10 +60,15 @@ class ProgressBar(object):
return self
def __str__(self):
- progressed = int(self.progress / self.step) #fix
+ progressed = int(self.progress / self.step) # fix
fill = progressed * self.fill
blank = (self.width - progressed) * self.blank
- return self.format % {'fill': fill, 'blank': blank, 'marker': self.marker, 'progress': int(self.progress)}
+ return self.format % {
+ 'fill': fill,
+ 'blank': blank,
+ 'marker': self.marker,
+ 'progress': int(
+ self.progress)}
__repr__ = __str__
@@ -80,17 +86,28 @@ class AnimatedProgressBar(ProgressBar):
Accepts an extra keyword argument named `stdout` (by default use sys.stdout)
and may be any file-object to which send the progress status.
"""
- def __init__(self,
- start=0,
- end=10,
- width=12,
- fill=six.unichr(0x25C9).encode("utf-8"),
- blank=six.unichr(0x25CC).encode("utf-8"),
- marker=six.unichr(0x25CE).encode("utf-8"),
- format='[%(fill)s%(marker)s%(blank)s] %(progress)s%%',
+
+ def __init__(self,
+ start=0,
+ end=10,
+ width=12,
+ fill=six.unichr(0x25C9).encode("utf-8"),
+ blank=six.unichr(0x25CC).encode("utf-8"),
+ marker=six.unichr(0x25CE).encode("utf-8"),
+ format='[%(fill)s%(marker)s%(blank)s] %(progress)s%%',
incremental=True,
stdout=sys.stdout):
- super(AnimatedProgressBar, self).__init__(start,end,width,fill,blank,marker,format,incremental)
+ super(
+ AnimatedProgressBar,
+ self).__init__(
+ start,
+ end,
+ width,
+ fill,
+ blank,
+ marker,
+ format,
+ incremental)
self.stdout = stdout
def show_progress(self):
@@ -101,25 +118,38 @@ class AnimatedProgressBar(ProgressBar):
self.stdout.write(str(self))
self.stdout.flush()
+
class ProgressWithEvents(AnimatedProgressBar):
"""Extends AnimatedProgressBar to allow you to track a set of events that
cause the progress to move. For instance, in a deletion progress bar, you
can track files that were nuked and files that the user doesn't have access to
"""
- def __init__(self,
- start=0,
- end=10,
- width=12,
- fill=six.unichr(0x25C9).encode("utf-8"),
- blank=six.unichr(0x25CC).encode("utf-8"),
- marker=six.unichr(0x25CE).encode("utf-8"),
- format='[%(fill)s%(marker)s%(blank)s] %(progress)s%%',
+
+ def __init__(self,
+ start=0,
+ end=10,
+ width=12,
+ fill=six.unichr(0x25C9).encode("utf-8"),
+ blank=six.unichr(0x25CC).encode("utf-8"),
+ marker=six.unichr(0x25CE).encode("utf-8"),
+ format='[%(fill)s%(marker)s%(blank)s] %(progress)s%%',
incremental=True,
stdout=sys.stdout):
- super(ProgressWithEvents, self).__init__(start,end,width,fill,blank,marker,format,incremental,stdout)
+ super(
+ ProgressWithEvents,
+ self).__init__(
+ start,
+ end,
+ width,
+ fill,
+ blank,
+ marker,
+ format,
+ incremental,
+ stdout)
self.events = {}
- def add_event(self,event):
+ def add_event(self, event):
if event in self.events:
self.events[event] += 1
else:
@@ -151,4 +181,4 @@ if __name__ == '__main__':
time.sleep(0.3)
if p.progress == 100:
break
- print() #new line \ No newline at end of file
+ print() # new line
OpenPOWER on IntegriCloud