From 0be545dc4513a15b88a7cfd94f713ee423575a09 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 25 May 2023 01:34:06 +0200 Subject: [PATCH] remove ProgressIndicatorEndless (not used) --- src/borg/helpers/__init__.py | 2 +- src/borg/helpers/progress.py | 34 ---------------------------------- src/borg/testsuite/helpers.py | 31 +------------------------------ 3 files changed, 2 insertions(+), 65 deletions(-) diff --git a/src/borg/helpers/__init__.py b/src/borg/helpers/__init__.py index e42d78415..1a745c49a 100644 --- a/src/borg/helpers/__init__.py +++ b/src/borg/helpers/__init__.py @@ -33,7 +33,7 @@ from .process import daemonize, daemonizing from .process import signal_handler, raising_signal_handler, sig_int, ignore_sigint, SigHup, SigTerm from .process import popen_with_error_handling, is_terminal, prepare_subprocess_env, create_filter_process -from .progress import ProgressIndicatorPercent, ProgressIndicatorEndless, ProgressIndicatorMessage +from .progress import ProgressIndicatorPercent, ProgressIndicatorMessage from .time import parse_timestamp, timestamp, safe_timestamp, safe_s, safe_ns, MAX_S, SUPPORT_32BIT_PLATFORMS from .time import format_time, format_timedelta, OutputTimestamp, archive_ts_now from .yes_no import yes, TRUISH, FALSISH, DEFAULTISH diff --git a/src/borg/helpers/progress.py b/src/borg/helpers/progress.py index 782c7fb34..f57446409 100644 --- a/src/borg/helpers/progress.py +++ b/src/borg/helpers/progress.py @@ -162,37 +162,3 @@ def output(self, message, justify=True, info=None): if justify: message = justify_to_terminal_size(message) self.logger.info(message) - - -class ProgressIndicatorEndless: - def __init__(self, step=10, file=None): - """ - Progress indicator (long row of dots) - - :param step: every Nth call, call the func - :param file: output file, default: sys.stderr - """ - self.counter = 0 # call counter - self.triggered = 0 # increases 1 per trigger event - self.step = step # trigger every calls - if file is None: - file = sys.stderr - self.file = file - - def progress(self): - self.counter += 1 - trigger = self.counter % self.step == 0 - if trigger: - self.triggered += 1 - return trigger - - def show(self): - trigger = self.progress() - if trigger: - return self.output(self.triggered) - - def output(self, triggered): - print(".", end="", file=self.file, flush=True) - - def finish(self): - print(file=self.file) diff --git a/src/borg/testsuite/helpers.py b/src/borg/testsuite/helpers.py index eba51b311..6e8dd55b3 100644 --- a/src/borg/testsuite/helpers.py +++ b/src/borg/testsuite/helpers.py @@ -34,7 +34,7 @@ from ..helpers import StableDict, bin_to_hex from ..helpers import parse_timestamp, ChunkIteratorFileWrapper, ChunkerParams from ..helpers import archivename_validator, text_validator -from ..helpers import ProgressIndicatorPercent, ProgressIndicatorEndless +from ..helpers import ProgressIndicatorPercent from ..helpers import swidth_slice from ..helpers import chunkit from ..helpers import safe_ns, safe_s, SUPPORT_32BIT_PLATFORMS @@ -1073,35 +1073,6 @@ def test_progress_percentage_quiet(capfd): assert err == "" -def test_progress_endless(capfd): - pi = ProgressIndicatorEndless(step=1, file=sys.stderr) - pi.show() - out, err = capfd.readouterr() - assert err == "." - pi.show() - out, err = capfd.readouterr() - assert err == "." - pi.finish() - out, err = capfd.readouterr() - assert err == "\n" - - -def test_progress_endless_step(capfd): - pi = ProgressIndicatorEndless(step=2, file=sys.stderr) - pi.show() - out, err = capfd.readouterr() - assert err == "" # no output here as we have step == 2 - pi.show() - out, err = capfd.readouterr() - assert err == "." - pi.show() - out, err = capfd.readouterr() - assert err == "" # no output here as we have step == 2 - pi.show() - out, err = capfd.readouterr() - assert err == "." - - def test_partial_format(): assert partial_format("{space:10}", {"space": " "}) == " " * 10 assert partial_format("{foobar}", {"bar": "wrong", "foobar": "correct"}) == "correct"