summaryrefslogtreecommitdiff
path: root/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress
diff options
context:
space:
mode:
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress')
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/__init__.py127
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/bar.py88
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/counter.py48
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/helpers.py91
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/spinner.py44
5 files changed, 0 insertions, 398 deletions
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/__init__.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/__init__.py
deleted file mode 100644
index 4aa97fc..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/__init__.py
+++ /dev/null
@@ -1,127 +0,0 @@
1# Copyright (c) 2012 Giorgos Verigakis <verigak@gmail.com>
2#
3# Permission to use, copy, modify, and distribute this software for any
4# purpose with or without fee is hereby granted, provided that the above
5# copyright notice and this permission notice appear in all copies.
6#
7# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
15from __future__ import division
16
17from collections import deque
18from datetime import timedelta
19from math import ceil
20from sys import stderr
21from time import time
22
23
24__version__ = '1.3'
25
26
27class Infinite(object):
28 file = stderr
29 sma_window = 10 # Simple Moving Average window
30
31 def __init__(self, *args, **kwargs):
32 self.index = 0
33 self.start_ts = time()
34 self.avg = 0
35 self._ts = self.start_ts
36 self._xput = deque(maxlen=self.sma_window)
37 for key, val in kwargs.items():
38 setattr(self, key, val)
39
40 def __getitem__(self, key):
41 if key.startswith('_'):
42 return None
43 return getattr(self, key, None)
44
45 @property
46 def elapsed(self):
47 return int(time() - self.start_ts)
48
49 @property
50 def elapsed_td(self):
51 return timedelta(seconds=self.elapsed)
52
53 def update_avg(self, n, dt):
54 if n > 0:
55 self._xput.append(dt / n)
56 self.avg = sum(self._xput) / len(self._xput)
57
58 def update(self):
59 pass
60
61 def start(self):
62 pass
63
64 def finish(self):
65 pass
66
67 def next(self, n=1):
68 now = time()
69 dt = now - self._ts
70 self.update_avg(n, dt)
71 self._ts = now
72 self.index = self.index + n
73 self.update()
74
75 def iter(self, it):
76 try:
77 for x in it:
78 yield x
79 self.next()
80 finally:
81 self.finish()
82
83
84class Progress(Infinite):
85 def __init__(self, *args, **kwargs):
86 super(Progress, self).__init__(*args, **kwargs)
87 self.max = kwargs.get('max', 100)
88
89 @property
90 def eta(self):
91 return int(ceil(self.avg * self.remaining))
92
93 @property
94 def eta_td(self):
95 return timedelta(seconds=self.eta)
96
97 @property
98 def percent(self):
99 return self.progress * 100
100
101 @property
102 def progress(self):
103 return min(1, self.index / self.max)
104
105 @property
106 def remaining(self):
107 return max(self.max - self.index, 0)
108
109 def start(self):
110 self.update()
111
112 def goto(self, index):
113 incr = index - self.index
114 self.next(incr)
115
116 def iter(self, it):
117 try:
118 self.max = len(it)
119 except TypeError:
120 pass
121
122 try:
123 for x in it:
124 yield x
125 self.next()
126 finally:
127 self.finish()
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/bar.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/bar.py
deleted file mode 100644
index 3fdd703..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/bar.py
+++ /dev/null
@@ -1,88 +0,0 @@
1# -*- coding: utf-8 -*-
2
3# Copyright (c) 2012 Giorgos Verigakis <verigak@gmail.com>
4#
5# Permission to use, copy, modify, and distribute this software for any
6# purpose with or without fee is hereby granted, provided that the above
7# copyright notice and this permission notice appear in all copies.
8#
9# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17from __future__ import unicode_literals
18from . import Progress
19from .helpers import WritelnMixin
20
21
22class Bar(WritelnMixin, Progress):
23 width = 32
24 message = ''
25 suffix = '%(index)d/%(max)d'
26 bar_prefix = ' |'
27 bar_suffix = '| '
28 empty_fill = ' '
29 fill = '#'
30 hide_cursor = True
31
32 def update(self):
33 filled_length = int(self.width * self.progress)
34 empty_length = self.width - filled_length
35
36 message = self.message % self
37 bar = self.fill * filled_length
38 empty = self.empty_fill * empty_length
39 suffix = self.suffix % self
40 line = ''.join([message, self.bar_prefix, bar, empty, self.bar_suffix,
41 suffix])
42 self.writeln(line)
43
44
45class ChargingBar(Bar):
46 suffix = '%(percent)d%%'
47 bar_prefix = ' '
48 bar_suffix = ' '
49 empty_fill = '∙'
50 fill = '█'
51
52
53class FillingSquaresBar(ChargingBar):
54 empty_fill = '▢'
55 fill = '▣'
56
57
58class FillingCirclesBar(ChargingBar):
59 empty_fill = '◯'
60 fill = '◉'
61
62
63class IncrementalBar(Bar):
64 phases = (' ', '▏', '▎', '▍', '▌', '▋', '▊', '▉', '█')
65
66 def update(self):
67 nphases = len(self.phases)
68 filled_len = self.width * self.progress
69 nfull = int(filled_len) # Number of full chars
70 phase = int((filled_len - nfull) * nphases) # Phase of last char
71 nempty = self.width - nfull # Number of empty chars
72
73 message = self.message % self
74 bar = self.phases[-1] * nfull
75 current = self.phases[phase] if phase > 0 else ''
76 empty = self.empty_fill * max(0, nempty - len(current))
77 suffix = self.suffix % self
78 line = ''.join([message, self.bar_prefix, bar, current, empty,
79 self.bar_suffix, suffix])
80 self.writeln(line)
81
82
83class PixelBar(IncrementalBar):
84 phases = ('⡀', '⡄', '⡆', '⡇', '⣇', '⣧', '⣷', '⣿')
85
86
87class ShadyBar(IncrementalBar):
88 phases = (' ', '░', '▒', '▓', '█')
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/counter.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/counter.py
deleted file mode 100644
index e993a51..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/counter.py
+++ /dev/null
@@ -1,48 +0,0 @@
1# -*- coding: utf-8 -*-
2
3# Copyright (c) 2012 Giorgos Verigakis <verigak@gmail.com>
4#
5# Permission to use, copy, modify, and distribute this software for any
6# purpose with or without fee is hereby granted, provided that the above
7# copyright notice and this permission notice appear in all copies.
8#
9# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17from __future__ import unicode_literals
18from . import Infinite, Progress
19from .helpers import WriteMixin
20
21
22class Counter(WriteMixin, Infinite):
23 message = ''
24 hide_cursor = True
25
26 def update(self):
27 self.write(str(self.index))
28
29
30class Countdown(WriteMixin, Progress):
31 hide_cursor = True
32
33 def update(self):
34 self.write(str(self.remaining))
35
36
37class Stack(WriteMixin, Progress):
38 phases = (' ', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█')
39 hide_cursor = True
40
41 def update(self):
42 nphases = len(self.phases)
43 i = min(nphases - 1, int(self.progress * nphases))
44 self.write(self.phases[i])
45
46
47class Pie(Stack):
48 phases = ('○', '◔', '◑', '◕', '●')
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/helpers.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/helpers.py
deleted file mode 100644
index 96c8800..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/helpers.py
+++ /dev/null
@@ -1,91 +0,0 @@
1# Copyright (c) 2012 Giorgos Verigakis <verigak@gmail.com>
2#
3# Permission to use, copy, modify, and distribute this software for any
4# purpose with or without fee is hereby granted, provided that the above
5# copyright notice and this permission notice appear in all copies.
6#
7# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
15from __future__ import print_function
16
17
18HIDE_CURSOR = '\x1b[?25l'
19SHOW_CURSOR = '\x1b[?25h'
20
21
22class WriteMixin(object):
23 hide_cursor = False
24
25 def __init__(self, message=None, **kwargs):
26 super(WriteMixin, self).__init__(**kwargs)
27 self._width = 0
28 if message:
29 self.message = message
30
31 if self.file.isatty():
32 if self.hide_cursor:
33 print(HIDE_CURSOR, end='', file=self.file)
34 print(self.message, end='', file=self.file)
35 self.file.flush()
36
37 def write(self, s):
38 if self.file.isatty():
39 b = '\b' * self._width
40 c = s.ljust(self._width)
41 print(b + c, end='', file=self.file)
42 self._width = max(self._width, len(s))
43 self.file.flush()
44
45 def finish(self):
46 if self.file.isatty() and self.hide_cursor:
47 print(SHOW_CURSOR, end='', file=self.file)
48
49
50class WritelnMixin(object):
51 hide_cursor = False
52
53 def __init__(self, message=None, **kwargs):
54 super(WritelnMixin, self).__init__(**kwargs)
55 if message:
56 self.message = message
57
58 if self.file.isatty() and self.hide_cursor:
59 print(HIDE_CURSOR, end='', file=self.file)
60
61 def clearln(self):
62 if self.file.isatty():
63 print('\r\x1b[K', end='', file=self.file)
64
65 def writeln(self, line):
66 if self.file.isatty():
67 self.clearln()
68 print(line, end='', file=self.file)
69 self.file.flush()
70
71 def finish(self):
72 if self.file.isatty():
73 print(file=self.file)
74 if self.hide_cursor:
75 print(SHOW_CURSOR, end='', file=self.file)
76
77
78from signal import signal, SIGINT
79from sys import exit
80
81
82class SigIntMixin(object):
83 """Registers a signal handler that calls finish on SIGINT"""
84
85 def __init__(self, *args, **kwargs):
86 super(SigIntMixin, self).__init__(*args, **kwargs)
87 signal(SIGINT, self._sigint_handler)
88
89 def _sigint_handler(self, signum, frame):
90 self.finish()
91 exit(0)
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/spinner.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/spinner.py
deleted file mode 100644
index d67c679..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/spinner.py
+++ /dev/null
@@ -1,44 +0,0 @@
1# -*- coding: utf-8 -*-
2
3# Copyright (c) 2012 Giorgos Verigakis <verigak@gmail.com>
4#
5# Permission to use, copy, modify, and distribute this software for any
6# purpose with or without fee is hereby granted, provided that the above
7# copyright notice and this permission notice appear in all copies.
8#
9# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17from __future__ import unicode_literals
18from . import Infinite
19from .helpers import WriteMixin
20
21
22class Spinner(WriteMixin, Infinite):
23 message = ''
24 phases = ('-', '\\', '|', '/')
25 hide_cursor = True
26
27 def update(self):
28 i = self.index % len(self.phases)
29 self.write(self.phases[i])
30
31
32class PieSpinner(Spinner):
33 phases = ['◷', '◶', '◵', '◴']
34
35
36class MoonSpinner(Spinner):
37 phases = ['◑', '◒', '◐', '◓']
38
39
40class LineSpinner(Spinner):
41 phases = ['⎺', '⎻', '⎼', '⎽', '⎼', '⎻']
42
43class PixelSpinner(Spinner):
44 phases = ['⣾','⣷', '⣯', '⣟', '⡿', '⢿', '⣻', '⣽']