mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-01 12:45:34 +00:00
remove ProgressIndicatorEndless (not used)
This commit is contained in:
parent
e351e67aee
commit
0be545dc45
3 changed files with 2 additions and 65 deletions
|
@ -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
|
||||
|
|
|
@ -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 <step> 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)
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue