progressbar2 4.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- docs/_theme/LICENSE +46 -0
- docs/_theme/flask_theme_support.py +89 -0
- docs/_theme/wolph/layout.html +27 -0
- docs/_theme/wolph/relations.html +19 -0
- docs/_theme/wolph/static/flasky.css_t +431 -0
- docs/_theme/wolph/static/small_flask.css +70 -0
- docs/_theme/wolph/theme.conf +7 -0
- progressbar/__about__.py +27 -0
- progressbar/__init__.py +81 -0
- progressbar/bar.py +1099 -0
- progressbar/base.py +31 -0
- progressbar/env.py +159 -0
- progressbar/multi.py +372 -0
- progressbar/py.typed +0 -0
- progressbar/shortcuts.py +22 -0
- progressbar/terminal/__init__.py +4 -0
- progressbar/terminal/base.py +524 -0
- progressbar/terminal/colors.py +1070 -0
- progressbar/terminal/os_specific/__init__.py +22 -0
- progressbar/terminal/os_specific/posix.py +15 -0
- progressbar/terminal/os_specific/windows.py +137 -0
- progressbar/terminal/stream.py +138 -0
- progressbar/utils.py +445 -0
- progressbar/widgets.py +1564 -0
- progressbar2-4.3.0.dist-info/LICENSE +28 -0
- progressbar2-4.3.0.dist-info/METADATA +442 -0
- progressbar2-4.3.0.dist-info/RECORD +30 -0
- progressbar2-4.3.0.dist-info/WHEEL +5 -0
- progressbar2-4.3.0.dist-info/entry_points.txt +2 -0
- progressbar2-4.3.0.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
|
|
3
|
+
if sys.platform.startswith('win'):
|
|
4
|
+
from .windows import (
|
|
5
|
+
getch as _getch,
|
|
6
|
+
reset_console_mode as _reset_console_mode,
|
|
7
|
+
set_console_mode as _set_console_mode,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
else:
|
|
11
|
+
from .posix import getch as _getch
|
|
12
|
+
|
|
13
|
+
def _reset_console_mode():
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
def _set_console_mode():
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
getch = _getch
|
|
21
|
+
reset_console_mode = _reset_console_mode
|
|
22
|
+
set_console_mode = _set_console_mode
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import termios
|
|
3
|
+
import tty
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def getch():
|
|
7
|
+
fd = sys.stdin.fileno()
|
|
8
|
+
old_settings = termios.tcgetattr(fd)
|
|
9
|
+
try:
|
|
10
|
+
tty.setraw(sys.stdin.fileno())
|
|
11
|
+
ch = sys.stdin.read(1)
|
|
12
|
+
finally:
|
|
13
|
+
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
|
|
14
|
+
|
|
15
|
+
return ch
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# ruff: noqa: N801
|
|
2
|
+
'''
|
|
3
|
+
Windows specific code for the terminal.
|
|
4
|
+
|
|
5
|
+
Note that the naming convention here is non-pythonic because we are
|
|
6
|
+
matching the Windows API naming.
|
|
7
|
+
'''
|
|
8
|
+
import ctypes
|
|
9
|
+
from ctypes.wintypes import (
|
|
10
|
+
BOOL as _BOOL,
|
|
11
|
+
CHAR as _CHAR,
|
|
12
|
+
DWORD as _DWORD,
|
|
13
|
+
HANDLE as _HANDLE,
|
|
14
|
+
SHORT as _SHORT,
|
|
15
|
+
UINT as _UINT,
|
|
16
|
+
WCHAR as _WCHAR,
|
|
17
|
+
WORD as _WORD,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
_kernel32 = ctypes.windll.Kernel32 # type: ignore
|
|
21
|
+
|
|
22
|
+
_ENABLE_VIRTUAL_TERMINAL_INPUT = 0x0200
|
|
23
|
+
_ENABLE_PROCESSED_OUTPUT = 0x0001
|
|
24
|
+
_ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004
|
|
25
|
+
|
|
26
|
+
_STD_INPUT_HANDLE = _DWORD(-10)
|
|
27
|
+
_STD_OUTPUT_HANDLE = _DWORD(-11)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
_GetConsoleMode = _kernel32.GetConsoleMode
|
|
31
|
+
_GetConsoleMode.restype = _BOOL
|
|
32
|
+
|
|
33
|
+
_SetConsoleMode = _kernel32.SetConsoleMode
|
|
34
|
+
_SetConsoleMode.restype = _BOOL
|
|
35
|
+
|
|
36
|
+
_GetStdHandle = _kernel32.GetStdHandle
|
|
37
|
+
_GetStdHandle.restype = _HANDLE
|
|
38
|
+
|
|
39
|
+
_ReadConsoleInput = _kernel32.ReadConsoleInputA
|
|
40
|
+
_ReadConsoleInput.restype = _BOOL
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
_h_console_input = _GetStdHandle(_STD_INPUT_HANDLE)
|
|
44
|
+
_input_mode = _DWORD()
|
|
45
|
+
_GetConsoleMode(_HANDLE(_h_console_input), ctypes.byref(_input_mode))
|
|
46
|
+
|
|
47
|
+
_h_console_output = _GetStdHandle(_STD_OUTPUT_HANDLE)
|
|
48
|
+
_output_mode = _DWORD()
|
|
49
|
+
_GetConsoleMode(_HANDLE(_h_console_output), ctypes.byref(_output_mode))
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class _COORD(ctypes.Structure):
|
|
53
|
+
_fields_ = (('X', _SHORT), ('Y', _SHORT))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class _FOCUS_EVENT_RECORD(ctypes.Structure):
|
|
57
|
+
_fields_ = ('bSetFocus', _BOOL)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class _KEY_EVENT_RECORD(ctypes.Structure):
|
|
61
|
+
class _uchar(ctypes.Union):
|
|
62
|
+
_fields_ = (('UnicodeChar', _WCHAR), ('AsciiChar', _CHAR))
|
|
63
|
+
|
|
64
|
+
_fields_ = (
|
|
65
|
+
('bKeyDown', _BOOL),
|
|
66
|
+
('wRepeatCount', _WORD),
|
|
67
|
+
('wVirtualKeyCode', _WORD),
|
|
68
|
+
('wVirtualScanCode', _WORD),
|
|
69
|
+
('uChar', _uchar),
|
|
70
|
+
('dwControlKeyState', _DWORD),
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class _MENU_EVENT_RECORD(ctypes.Structure):
|
|
75
|
+
_fields_ = ('dwCommandId', _UINT)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class _MOUSE_EVENT_RECORD(ctypes.Structure):
|
|
79
|
+
_fields_ = (
|
|
80
|
+
('dwMousePosition', _COORD),
|
|
81
|
+
('dwButtonState', _DWORD),
|
|
82
|
+
('dwControlKeyState', _DWORD),
|
|
83
|
+
('dwEventFlags', _DWORD),
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class _WINDOW_BUFFER_SIZE_RECORD(ctypes.Structure):
|
|
88
|
+
_fields_ = ('dwSize', _COORD)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class _INPUT_RECORD(ctypes.Structure):
|
|
92
|
+
class _Event(ctypes.Union):
|
|
93
|
+
_fields_ = (
|
|
94
|
+
('KeyEvent', _KEY_EVENT_RECORD),
|
|
95
|
+
('MouseEvent', _MOUSE_EVENT_RECORD),
|
|
96
|
+
('WindowBufferSizeEvent', _WINDOW_BUFFER_SIZE_RECORD),
|
|
97
|
+
('MenuEvent', _MENU_EVENT_RECORD),
|
|
98
|
+
('FocusEvent', _FOCUS_EVENT_RECORD),
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
_fields_ = (('EventType', _WORD), ('Event', _Event))
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def reset_console_mode():
|
|
105
|
+
_SetConsoleMode(_HANDLE(_h_console_input), _DWORD(_input_mode.value))
|
|
106
|
+
_SetConsoleMode(_HANDLE(_h_console_output), _DWORD(_output_mode.value))
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def set_console_mode():
|
|
110
|
+
mode = _input_mode.value | _ENABLE_VIRTUAL_TERMINAL_INPUT
|
|
111
|
+
_SetConsoleMode(_HANDLE(_h_console_input), _DWORD(mode))
|
|
112
|
+
|
|
113
|
+
mode = (
|
|
114
|
+
_output_mode.value
|
|
115
|
+
| _ENABLE_PROCESSED_OUTPUT
|
|
116
|
+
| _ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
|
117
|
+
)
|
|
118
|
+
_SetConsoleMode(_HANDLE(_h_console_output), _DWORD(mode))
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def getch():
|
|
122
|
+
lp_buffer = (_INPUT_RECORD * 2)()
|
|
123
|
+
n_length = _DWORD(2)
|
|
124
|
+
lp_number_of_events_read = _DWORD()
|
|
125
|
+
|
|
126
|
+
_ReadConsoleInput(
|
|
127
|
+
_HANDLE(_h_console_input),
|
|
128
|
+
lp_buffer,
|
|
129
|
+
n_length,
|
|
130
|
+
ctypes.byref(lp_number_of_events_read),
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
char = lp_buffer[1].Event.KeyEvent.uChar.AsciiChar.decode('ascii')
|
|
134
|
+
if char == '\x00':
|
|
135
|
+
return None
|
|
136
|
+
|
|
137
|
+
return char
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
import typing
|
|
5
|
+
from types import TracebackType
|
|
6
|
+
from typing import Iterable, Iterator
|
|
7
|
+
|
|
8
|
+
from progressbar import base
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TextIOOutputWrapper(base.TextIO): # pragma: no cover
|
|
12
|
+
def __init__(self, stream: base.TextIO):
|
|
13
|
+
self.stream = stream
|
|
14
|
+
|
|
15
|
+
def close(self) -> None:
|
|
16
|
+
self.stream.close()
|
|
17
|
+
|
|
18
|
+
def fileno(self) -> int:
|
|
19
|
+
return self.stream.fileno()
|
|
20
|
+
|
|
21
|
+
def flush(self) -> None:
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
def isatty(self) -> bool:
|
|
25
|
+
return self.stream.isatty()
|
|
26
|
+
|
|
27
|
+
def read(self, __n: int = -1) -> str:
|
|
28
|
+
return self.stream.read(__n)
|
|
29
|
+
|
|
30
|
+
def readable(self) -> bool:
|
|
31
|
+
return self.stream.readable()
|
|
32
|
+
|
|
33
|
+
def readline(self, __limit: int = -1) -> str:
|
|
34
|
+
return self.stream.readline(__limit)
|
|
35
|
+
|
|
36
|
+
def readlines(self, __hint: int = -1) -> list[str]:
|
|
37
|
+
return self.stream.readlines(__hint)
|
|
38
|
+
|
|
39
|
+
def seek(self, __offset: int, __whence: int = 0) -> int:
|
|
40
|
+
return self.stream.seek(__offset, __whence)
|
|
41
|
+
|
|
42
|
+
def seekable(self) -> bool:
|
|
43
|
+
return self.stream.seekable()
|
|
44
|
+
|
|
45
|
+
def tell(self) -> int:
|
|
46
|
+
return self.stream.tell()
|
|
47
|
+
|
|
48
|
+
def truncate(self, __size: int | None = None) -> int:
|
|
49
|
+
return self.stream.truncate(__size)
|
|
50
|
+
|
|
51
|
+
def writable(self) -> bool:
|
|
52
|
+
return self.stream.writable()
|
|
53
|
+
|
|
54
|
+
def writelines(self, __lines: Iterable[str]) -> None:
|
|
55
|
+
return self.stream.writelines(__lines)
|
|
56
|
+
|
|
57
|
+
def __next__(self) -> str:
|
|
58
|
+
return self.stream.__next__()
|
|
59
|
+
|
|
60
|
+
def __iter__(self) -> Iterator[str]:
|
|
61
|
+
return self.stream.__iter__()
|
|
62
|
+
|
|
63
|
+
def __exit__(
|
|
64
|
+
self,
|
|
65
|
+
__t: type[BaseException] | None,
|
|
66
|
+
__value: BaseException | None,
|
|
67
|
+
__traceback: TracebackType | None,
|
|
68
|
+
) -> None:
|
|
69
|
+
return self.stream.__exit__(__t, __value, __traceback)
|
|
70
|
+
|
|
71
|
+
def __enter__(self) -> base.TextIO:
|
|
72
|
+
return self.stream.__enter__()
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class LineOffsetStreamWrapper(TextIOOutputWrapper):
|
|
76
|
+
UP = '\033[F'
|
|
77
|
+
DOWN = '\033[B'
|
|
78
|
+
|
|
79
|
+
def __init__(self, lines=0, stream=sys.stderr):
|
|
80
|
+
self.lines = lines
|
|
81
|
+
super().__init__(stream)
|
|
82
|
+
|
|
83
|
+
def write(self, data):
|
|
84
|
+
# Move the cursor up
|
|
85
|
+
self.stream.write(self.UP * self.lines)
|
|
86
|
+
# Print a carriage return to reset the cursor position
|
|
87
|
+
self.stream.write('\r')
|
|
88
|
+
# Print the data without newlines so we don't change the position
|
|
89
|
+
self.stream.write(data.rstrip('\n'))
|
|
90
|
+
# Move the cursor down
|
|
91
|
+
self.stream.write(self.DOWN * self.lines)
|
|
92
|
+
|
|
93
|
+
self.flush()
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class LastLineStream(TextIOOutputWrapper):
|
|
97
|
+
line: str = ''
|
|
98
|
+
|
|
99
|
+
def seekable(self) -> bool:
|
|
100
|
+
return False
|
|
101
|
+
|
|
102
|
+
def readable(self) -> bool:
|
|
103
|
+
return True
|
|
104
|
+
|
|
105
|
+
def read(self, __n: int = -1) -> str:
|
|
106
|
+
if __n < 0:
|
|
107
|
+
return self.line
|
|
108
|
+
else:
|
|
109
|
+
return self.line[:__n]
|
|
110
|
+
|
|
111
|
+
def readline(self, __limit: int = -1) -> str:
|
|
112
|
+
if __limit < 0:
|
|
113
|
+
return self.line
|
|
114
|
+
else:
|
|
115
|
+
return self.line[:__limit]
|
|
116
|
+
|
|
117
|
+
def write(self, data: str) -> int:
|
|
118
|
+
self.line = data
|
|
119
|
+
return len(data)
|
|
120
|
+
|
|
121
|
+
def truncate(self, __size: int | None = None) -> int:
|
|
122
|
+
if __size is None:
|
|
123
|
+
self.line = ''
|
|
124
|
+
else:
|
|
125
|
+
self.line = self.line[:__size]
|
|
126
|
+
|
|
127
|
+
return len(self.line)
|
|
128
|
+
|
|
129
|
+
def __iter__(self) -> typing.Generator[str, typing.Any, typing.Any]:
|
|
130
|
+
yield self.line
|
|
131
|
+
|
|
132
|
+
def writelines(self, __lines: Iterable[str]) -> None:
|
|
133
|
+
line = ''
|
|
134
|
+
# Walk through the lines and take the last one
|
|
135
|
+
for line in __lines: # noqa: B007
|
|
136
|
+
pass
|
|
137
|
+
|
|
138
|
+
self.line = line
|