Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
diffoscope
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Reproducible Builds
diffoscope
Commits
1fae3be4
Commit
1fae3be4
authored
1 year ago
by
Vekhir
Committed by
Chris Lamb
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Add compatibility for progressbar 2.5 as available on Debian
parent
61394cc4
No related branches found
No related tags found
1 merge request
!135
Update to progressbar >= 3.0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
diffoscope/progress.py
+23
-0
23 additions, 0 deletions
diffoscope/progress.py
with
23 additions
and
0 deletions
diffoscope/progress.py
+
23
−
0
View file @
1fae3be4
...
...
@@ -207,9 +207,11 @@ class ProgressBar:
def
__init__
(
self
):
try
:
from
progressbar.widgets
import
WidgetBase
self
.
compatibility_mode
=
False
except
ImportError
:
# Fallback to the older Debian version
from
progressbar
import
Widget
as
WidgetBase
self
.
compatibility_mode
=
True
self
.
msg
=
""
...
...
@@ -224,6 +226,10 @@ class ProgressBar:
# Print the last `width` characters with an ellipsis.
return
"
…{}
"
.
format
(
msg
[
-
width
+
1
:])
def
update
(
self
,
pbar
,
_observer
=
self
):
"""
Compatibility method for progressbar 2.5
"""
return
self
(
pbar
,
None
,
_observer
)
class
OurProgressBar
(
progressbar
.
ProgressBar
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
# Remove after https://github.com/niltonvolpato/python-progressbar/pull/57 is fixed.
...
...
@@ -235,12 +241,21 @@ class ProgressBar:
def
_needs_update
(
self
):
return
True
def
_need_update
(
self
):
"""
Compatibility method for progressbar 2.5
"""
return
self
.
_needs_update
()
def
erase_line
(
self
):
if
self
.
erase_to_eol
:
self
.
fd
.
buffer
.
write
(
self
.
erase_to_eol
)
self
.
fd
.
flush
()
def
finish
(
self
):
if
self
.
compatibility_mode
:
# setting self.finished = True makes super().finish() a noop
self
.
finished
=
True
self
.
update
(
self
.
maxval
)
super
().
finish
()
# Clear the progress bar after completion
self
.
erase_line
()
...
...
@@ -260,10 +275,18 @@ class ProgressBar:
"
"
,
)
)
if
self
.
compatibility_mode
:
self
.
bar
.
start
()
def
notify
(
self
,
current
,
total
,
msg
):
self
.
msg
=
msg
if
self
.
compatibility_mode
:
self
.
bar
.
maxval
=
total
self
.
bar
.
value
=
current
self
.
bar
.
update
()
return
self
.
bar
.
max_value
=
total
self
.
bar
.
update
(
current
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment