@@ -48,9 +48,11 @@ class ProgressBar(Protocol):
4848 A brief description of the current step (e.g. "Scanning contents",
4949 "OCR", "PDF/A conversion"). OCRmyPDF updates this before each major step.
5050 unit (str | None):
51- A short label for the type of work being tracked (e.g. "page", "%", "image").
51+ A short label for the type of work being tracked
52+ (e.g. "page", "%", "image").
5253 disable (bool):
53- If ``True``, progress updates are suppressed (no output). Defaults to ``False``.
54+ If ``True``, progress updates are suppressed (no output).
55+ Defaults to ``False``.
5456 **kwargs:
5557 Future or extra parameters that OCRmyPDF might pass. Implementations
5658 should accept and ignore unrecognized keywords gracefully.
@@ -64,7 +66,9 @@ class ProgressBar(Protocol):
6466 from ocrmypdf import hookimpl
6567
6668 class ConsoleProgressBar(ProgressBar):
67- def __init__(self, *, total=None, desc=None, unit=None, disable=False, **kwargs):
69+ def __init__(
70+ self, *, total=None, desc=None, unit=None, disable=False, **kwargs
71+ ):
6872 self.total = total
6973 self.desc = desc
7074 self.unit = unit
@@ -73,7 +77,10 @@ def __init__(self, *, total=None, desc=None, unit=None, disable=False, **kwargs)
7377
7478 def __enter__(self):
7579 if not self.disable:
76- print(f"Starting {self.desc or 'an OCR task'} (total={self.total} {self.unit})")
80+ print(
81+ f"Starting {self.desc or 'an OCR task'} "
82+ f"(total={self.total} {self.unit})"
83+ )
7784 return self
7885
7986 def __exit__(self, exc_type, exc_value, traceback):
@@ -86,15 +93,19 @@ def __exit__(self, exc_type, exc_value, traceback):
8693
8794 def update(self, n=1, *, completed=None):
8895 if completed is not None:
89- # If 'completed' is given, you could set self.current = completed
96+ # If 'completed' is given, you could set
97+ # self.current = completed
9098 # but let's just read it to show usage
9199 print(f"Absolute completion reported: {completed}")
92100 # Otherwise, we increment by 'n'
93101 self.current += n
94102 if not self.disable:
95103 if self.total:
96104 percent = (self.current / self.total) * 100
97- print(f"{self.desc}: {self.current}/{self.total} ({percent:.1f}%)")
105+ print(
106+ f"{self.desc}: {self.current}/{self.total}"
107+ f"({percent:.1f}%)"
108+ )
98109 else:
99110 print(f"{self.desc}: {self.current} units done")
100111
0 commit comments