Skip to content

Commit fcbf77b

Browse files
committed
Merge branch 'release/4.0.0'
2 parents 005d8a1 + e84e267 commit fcbf77b

File tree

13 files changed

+147
-203
lines changed

13 files changed

+147
-203
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
timeout-minutes: 10
1212
strategy:
1313
matrix:
14-
python-version: [3.6, 3.7, 3.8, 3.9]
14+
python-version: ['3.7', '3.8', '3.9', '3.10']
1515

1616
steps:
1717
- uses: actions/checkout@v2

examples.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
33

4-
from __future__ import absolute_import
5-
from __future__ import division
6-
from __future__ import print_function
7-
from __future__ import unicode_literals
8-
from __future__ import with_statement
9-
104
import functools
115
import random
126
import sys
@@ -187,7 +181,10 @@ def granular_progress_example():
187181
progressbar.GranularBar(markers=" ⡀⡄⡆⡇⣇⣧⣷⣿", left='', right='|'),
188182
progressbar.GranularBar(markers=" .oO", left='', right=''),
189183
]
190-
for i in progressbar.progressbar(range(100), widgets=widgets):
184+
for i in progressbar.progressbar(list(range(100)), widgets=widgets):
185+
time.sleep(0.03)
186+
187+
for i in progressbar.progressbar(iter(range(100)), widgets=widgets):
191188
time.sleep(0.03)
192189

193190

progressbar/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
long running operations.
2020
'''.strip().split())
2121
__email__ = '[email protected]'
22-
__version__ = '3.55.0'
22+
__version__ = '4.0.0'
2323
__license__ = 'BSD'
2424
__copyright__ = 'Copyright 2015 Rick van Hattem (Wolph)'
2525
__url__ = 'https://github.com/WoLpH/python-progressbar'

progressbar/__init__.py

Lines changed: 34 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,40 @@
11
from datetime import date
22

3-
from .utils import (
4-
len_color,
5-
streams
6-
)
7-
from .shortcuts import progressbar
8-
9-
from .widgets import (
10-
Timer,
11-
ETA,
12-
AdaptiveETA,
13-
AbsoluteETA,
14-
DataSize,
15-
FileTransferSpeed,
16-
AdaptiveTransferSpeed,
17-
AnimatedMarker,
18-
Counter,
19-
Percentage,
20-
FormatLabel,
21-
SimpleProgress,
22-
Bar,
23-
ReverseBar,
24-
BouncingBar,
25-
RotatingMarker,
26-
VariableMixin,
27-
MultiRangeBar,
28-
MultiProgressBar,
29-
GranularBar,
30-
FormatLabelBar,
31-
PercentageLabelBar,
32-
Variable,
33-
DynamicMessage,
34-
FormatCustomText,
35-
CurrentTime
36-
)
37-
38-
from .bar import (
39-
ProgressBar,
40-
DataTransferBar,
41-
NullBar,
42-
)
3+
from .__about__ import __author__
4+
from .__about__ import __version__
5+
from .bar import DataTransferBar
6+
from .bar import NullBar
7+
from .bar import ProgressBar
438
from .base import UnknownLength
44-
45-
46-
from .__about__ import (
47-
__author__,
48-
__version__,
49-
)
9+
from .shortcuts import progressbar
10+
from .utils import len_color
11+
from .utils import streams
12+
from .widgets import AbsoluteETA
13+
from .widgets import AdaptiveETA
14+
from .widgets import AdaptiveTransferSpeed
15+
from .widgets import AnimatedMarker
16+
from .widgets import Bar
17+
from .widgets import BouncingBar
18+
from .widgets import Counter
19+
from .widgets import CurrentTime
20+
from .widgets import DataSize
21+
from .widgets import DynamicMessage
22+
from .widgets import ETA
23+
from .widgets import FileTransferSpeed
24+
from .widgets import FormatCustomText
25+
from .widgets import FormatLabel
26+
from .widgets import FormatLabelBar
27+
from .widgets import GranularBar
28+
from .widgets import MultiProgressBar
29+
from .widgets import MultiRangeBar
30+
from .widgets import Percentage
31+
from .widgets import PercentageLabelBar
32+
from .widgets import ReverseBar
33+
from .widgets import RotatingMarker
34+
from .widgets import SimpleProgress
35+
from .widgets import Timer
36+
from .widgets import Variable
37+
from .widgets import VariableMixin
5038

5139
__date__ = str(date.today())
5240
__all__ = [

progressbar/bar.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
1-
from __future__ import absolute_import
2-
from __future__ import division
3-
from __future__ import unicode_literals
4-
from __future__ import with_statement
1+
from __future__ import annotations
52

6-
import sys
3+
import logging
74
import math
85
import os
6+
import sys
97
import time
108
import timeit
11-
import logging
129
import warnings
13-
from datetime import datetime
1410
from copy import deepcopy
11+
from datetime import datetime
12+
13+
from python_utils import types
14+
1515
try: # pragma: no cover
1616
from collections import abc
1717
except ImportError: # pragma: no cover
1818
import collections as abc
1919

2020
from python_utils import converters
2121

22-
import six
23-
2422
from . import widgets
2523
from . import widgets as widgets_module # Avoid name collision
2624
from . import base
2725
from . import utils
2826

29-
3027
logger = logging.getLogger(__name__)
3128

3229

@@ -58,8 +55,10 @@ class ProgressBarBase(abc.Iterable, ProgressBarMixinBase):
5855

5956
class DefaultFdMixin(ProgressBarMixinBase):
6057

61-
def __init__(self, fd=sys.stderr, is_terminal=None, line_breaks=None,
62-
enable_colors=None, **kwargs):
58+
def __init__(self, fd: types.IO = sys.stderr,
59+
is_terminal: bool | None = None,
60+
line_breaks: bool | None = None,
61+
enable_colors: bool | None = None, **kwargs):
6362
if fd is sys.stdout:
6463
fd = utils.streams.original_stdout
6564

@@ -76,8 +75,8 @@ def __init__(self, fd=sys.stderr, is_terminal=None, line_breaks=None,
7675
# Check if it should overwrite the current line (suitable for
7776
# iteractive terminals) or write line breaks (suitable for log files)
7877
if line_breaks is None:
79-
line_breaks = utils.env_flag('PROGRESSBAR_LINE_BREAKS', not
80-
self.is_terminal)
78+
line_breaks = utils.env_flag('PROGRESSBAR_LINE_BREAKS',
79+
not self.is_terminal)
8180
self.line_breaks = line_breaks
8281

8382
# Check if ANSI escape characters are enabled (suitable for iteractive
@@ -122,7 +121,7 @@ def finish(self, *args, **kwargs): # pragma: no cover
122121

123122
class ResizableMixin(ProgressBarMixinBase):
124123

125-
def __init__(self, term_width=None, **kwargs):
124+
def __init__(self, term_width: int | None = None, **kwargs):
126125
ProgressBarMixinBase.__init__(self, **kwargs)
127126

128127
self.signal_set = False
@@ -156,7 +155,8 @@ def finish(self): # pragma: no cover
156155

157156
class StdRedirectMixin(DefaultFdMixin):
158157

159-
def __init__(self, redirect_stderr=False, redirect_stdout=False, **kwargs):
158+
def __init__(self, redirect_stderr: bool = False,
159+
redirect_stdout: bool = False, **kwargs):
160160
DefaultFdMixin.__init__(self, **kwargs)
161161
self.redirect_stderr = redirect_stderr
162162
self.redirect_stdout = redirect_stdout
@@ -179,7 +179,7 @@ def start(self, *args, **kwargs):
179179
utils.streams.start_capturing(self)
180180
DefaultFdMixin.start(self, *args, **kwargs)
181181

182-
def update(self, value=None):
182+
def update(self, value: float = None):
183183
if not self.line_breaks and utils.streams.needs_clear():
184184
self.fd.write('\r' + ' ' * self.term_width + '\r')
185185

@@ -197,7 +197,6 @@ def finish(self, end='\n'):
197197

198198

199199
class ProgressBar(StdRedirectMixin, ResizableMixin, ProgressBarBase):
200-
201200
'''The ProgressBar class which updates and prints the bar.
202201
203202
Args:
@@ -488,8 +487,8 @@ def data(self):
488487
# The seconds since the bar started
489488
total_seconds_elapsed=total_seconds_elapsed,
490489
# The seconds since the bar started modulo 60
491-
seconds_elapsed=(elapsed.seconds % 60) +
492-
(elapsed.microseconds / 1000000.),
490+
seconds_elapsed=(elapsed.seconds % 60)
491+
+ (elapsed.microseconds / 1000000.),
493492
# The minutes since the bar started modulo 60
494493
minutes_elapsed=(elapsed.seconds / 60) % 60,
495494
# The hours since the bar started modulo 24
@@ -585,7 +584,7 @@ def _format_widgets(self):
585584
elif isinstance(widget, widgets.AutoWidthWidgetBase):
586585
result.append(widget)
587586
expanding.insert(0, index)
588-
elif isinstance(widget, six.string_types):
587+
elif isinstance(widget, str):
589588
result.append(widget)
590589
width -= self.custom_len(widget)
591590
else:
@@ -795,6 +794,7 @@ class DataTransferBar(ProgressBar):
795794
796795
This assumes that the values its given are numbers of bytes.
797796
'''
797+
798798
def default_widgets(self):
799799
if self.max_value:
800800
return [
@@ -813,7 +813,6 @@ def default_widgets(self):
813813

814814

815815
class NullBar(ProgressBar):
816-
817816
'''
818817
Progress bar that does absolutely nothing. Useful for single verbosity
819818
flags

progressbar/base.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
# -*- mode: python; coding: utf-8 -*-
2-
from __future__ import absolute_import
3-
import six
4-
52

63
class FalseMeta(type):
74
def __bool__(self): # pragma: no cover
@@ -13,9 +10,9 @@ def __cmp__(self, other): # pragma: no cover
1310
__nonzero__ = __bool__
1411

1512

16-
class UnknownLength(six.with_metaclass(FalseMeta, object)):
13+
class UnknownLength(metaclass=FalseMeta):
1714
pass
1815

1916

20-
class Undefined(six.with_metaclass(FalseMeta, object)):
17+
class Undefined(metaclass=FalseMeta):
2118
pass

0 commit comments

Comments
 (0)