Mercurial > repos > guerler > hhblits
comparison lib/python3.8/site-packages/pip/_vendor/progress/bar.py @ 0:9e54283cc701 draft
"planemo upload commit d12c32a45bcd441307e632fca6d9af7d60289d44"
author | guerler |
---|---|
date | Mon, 27 Jul 2020 03:47:31 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:9e54283cc701 |
---|---|
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 | |
17 from __future__ import unicode_literals | |
18 | |
19 import sys | |
20 | |
21 from . import Progress | |
22 | |
23 | |
24 class Bar(Progress): | |
25 width = 32 | |
26 suffix = '%(index)d/%(max)d' | |
27 bar_prefix = ' |' | |
28 bar_suffix = '| ' | |
29 empty_fill = ' ' | |
30 fill = '#' | |
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 | |
45 class ChargingBar(Bar): | |
46 suffix = '%(percent)d%%' | |
47 bar_prefix = ' ' | |
48 bar_suffix = ' ' | |
49 empty_fill = '∙' | |
50 fill = '█' | |
51 | |
52 | |
53 class FillingSquaresBar(ChargingBar): | |
54 empty_fill = '▢' | |
55 fill = '▣' | |
56 | |
57 | |
58 class FillingCirclesBar(ChargingBar): | |
59 empty_fill = '◯' | |
60 fill = '◉' | |
61 | |
62 | |
63 class IncrementalBar(Bar): | |
64 if sys.platform.startswith('win'): | |
65 phases = (u' ', u'▌', u'█') | |
66 else: | |
67 phases = (' ', '▏', '▎', '▍', '▌', '▋', '▊', '▉', '█') | |
68 | |
69 def update(self): | |
70 nphases = len(self.phases) | |
71 filled_len = self.width * self.progress | |
72 nfull = int(filled_len) # Number of full chars | |
73 phase = int((filled_len - nfull) * nphases) # Phase of last char | |
74 nempty = self.width - nfull # Number of empty chars | |
75 | |
76 message = self.message % self | |
77 bar = self.phases[-1] * nfull | |
78 current = self.phases[phase] if phase > 0 else '' | |
79 empty = self.empty_fill * max(0, nempty - len(current)) | |
80 suffix = self.suffix % self | |
81 line = ''.join([message, self.bar_prefix, bar, current, empty, | |
82 self.bar_suffix, suffix]) | |
83 self.writeln(line) | |
84 | |
85 | |
86 class PixelBar(IncrementalBar): | |
87 phases = ('⡀', '⡄', '⡆', '⡇', '⣇', '⣧', '⣷', '⣿') | |
88 | |
89 | |
90 class ShadyBar(IncrementalBar): | |
91 phases = (' ', '░', '▒', '▓', '█') |