FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-progressbar/progressbar/terminal/stream.py at develop · commit-0/python-progressbar · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
commit-0
/
python-progressbar
Public
forked from
wolph/python-progressbar
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-progressbar
/
progressbar
/
terminal
/
stream.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
142 lines (103 loc) · 3.6 KB
Breadcrumbs
python-progressbar
/
progressbar
/
terminal
/
stream.py
Copy path
File metadata and controls
142 lines (103 loc) · 3.6 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
from
__future__
import
annotations
import
sys
import
typing
from
types
import
TracebackType
from
typing
import
Iterable
,
Iterator
from
progressbar
import
base
class
TextIOOutputWrapper
(
base
.
TextIO
):
# pragma: no cover
def
__init__
(
self
,
stream
:
base
.
TextIO
)
->
None
:
self
.
stream
=
stream
def
close
(
self
)
->
None
:
self
.
stream
.
close
()
def
fileno
(
self
)
->
int
:
return
self
.
stream
.
fileno
()
def
flush
(
self
)
->
None
:
pass
def
isatty
(
self
)
->
bool
:
return
self
.
stream
.
isatty
()
def
read
(
self
,
__n
:
int
=
-
1
)
->
str
:
return
self
.
stream
.
read
(
__n
)
def
readable
(
self
)
->
bool
:
return
self
.
stream
.
readable
()
def
readline
(
self
,
__limit
:
int
=
-
1
)
->
str
:
return
self
.
stream
.
readline
(
__limit
)
def
readlines
(
self
,
__hint
:
int
=
-
1
)
->
list
[
str
]:
return
self
.
stream
.
readlines
(
__hint
)
def
seek
(
self
,
__offset
:
int
,
__whence
:
int
=
0
)
->
int
:
return
self
.
stream
.
seek
(
__offset
,
__whence
)
def
seekable
(
self
)
->
bool
:
return
self
.
stream
.
seekable
()
def
tell
(
self
)
->
int
:
return
self
.
stream
.
tell
()
def
truncate
(
self
,
__size
:
int
|
None
=
None
)
->
int
:
return
self
.
stream
.
truncate
(
__size
)
def
writable
(
self
)
->
bool
:
return
self
.
stream
.
writable
()
def
writelines
(
self
,
__lines
:
Iterable
[
str
])
->
None
:
return
self
.
stream
.
writelines
(
__lines
)
def
__next__
(
self
)
->
str
:
return
self
.
stream
.
__next__
()
def
__iter__
(
self
)
->
Iterator
[
str
]:
return
self
.
stream
.
__iter__
()
def
__exit__
(
self
,
__t
:
type
[
BaseException
]
|
None
,
__value
:
BaseException
|
None
,
__traceback
:
TracebackType
|
None
,
)
->
None
:
return
self
.
stream
.
__exit__
(
__t
,
__value
,
__traceback
)
def
__enter__
(
self
)
->
base
.
TextIO
:
return
self
.
stream
.
__enter__
()
class
LineOffsetStreamWrapper
(
TextIOOutputWrapper
):
UP
=
'
\033
[F'
DOWN
=
'
\033
[B'
def
__init__
(
self
,
lines
:
int
=
0
,
stream
:
typing
.
TextIO
=
sys
.
stderr
)
->
None
:
self
.
lines
=
lines
super
().
__init__
(
stream
)
def
write
(
self
,
data
:
str
)
->
int
:
data
=
data
.
rstrip
(
'
\n
'
)
# Move the cursor up
self
.
stream
.
write
(
self
.
UP
*
self
.
lines
)
# Print a carriage return to reset the cursor position
self
.
stream
.
write
(
'
\r
'
)
# Print the data without newlines so we don't change the position
self
.
stream
.
write
(
data
)
# Move the cursor down
self
.
stream
.
write
(
self
.
DOWN
*
self
.
lines
)
self
.
flush
()
return
len
(
data
)
class
LastLineStream
(
TextIOOutputWrapper
):
line
:
str
=
''
def
seekable
(
self
)
->
bool
:
return
False
def
readable
(
self
)
->
bool
:
return
True
def
read
(
self
,
__n
:
int
=
-
1
)
->
str
:
if
__n
<
0
:
return
self
.
line
else
:
return
self
.
line
[:
__n
]
def
readline
(
self
,
__limit
:
int
=
-
1
)
->
str
:
if
__limit
<
0
:
return
self
.
line
else
:
return
self
.
line
[:
__limit
]
def
write
(
self
,
data
:
str
)
->
int
:
self
.
line
=
data
return
len
(
data
)
def
truncate
(
self
,
__size
:
int
|
None
=
None
)
->
int
:
if
__size
is
None
:
self
.
line
=
''
else
:
self
.
line
=
self
.
line
[:
__size
]
return
len
(
self
.
line
)
def
__iter__
(
self
)
->
typing
.
Generator
[
str
,
typing
.
Any
,
typing
.
Any
]:
yield
self
.
line
def
writelines
(
self
,
__lines
:
Iterable
[
str
])
->
None
:
line
=
''
# Walk through the lines and take the last one
for
line
in
__lines
:
# noqa: B007
pass
self
.
line
=
line
Back
|
FazBrowse Home
|
New Git URL