diff options
author | Shubham Saini <shubham6405@gmail.com> | 2019-08-05 08:32:33 +0000 |
---|---|---|
committer | Shubham Saini <shubham6405@gmail.com> | 2019-08-05 08:32:33 +0000 |
commit | 227b2d30a8675b44918f9d9ca89b24144a938215 (patch) | |
tree | 9f8e6a28724514b6fdf463a9ab2067a7ef309b72 /venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/__init__.py | |
parent | 842a8cfbbbdb1f92889d892e4859dbd5d40c5be8 (diff) |
removing venv files
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/__init__.py')
-rw-r--r-- | venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/progress/__init__.py | 127 |
1 files changed, 0 insertions, 127 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 | |||
15 | from __future__ import division | ||
16 | |||
17 | from collections import deque | ||
18 | from datetime import timedelta | ||
19 | from math import ceil | ||
20 | from sys import stderr | ||
21 | from time import time | ||
22 | |||
23 | |||
24 | __version__ = '1.3' | ||
25 | |||
26 | |||
27 | class 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 | |||
84 | class 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() | ||