Fix calls to hook.get_executor
This commit is contained in:
+1
-1
@@ -140,7 +140,7 @@ Execution and progress reporting
|
||||
|
||||
.. autofunction:: ocrmypdf.pluginspec.get_executor
|
||||
|
||||
.. autofunction:: ocrmypdf.pluginspec.get_progress_bar
|
||||
.. autofunction:: ocrmypdf.pluginspec.get_progressbar_class
|
||||
|
||||
Applying special behavior before processing
|
||||
-------------------------------------------
|
||||
|
||||
@@ -107,8 +107,8 @@ class Executor(ABC):
|
||||
|
||||
|
||||
def setup_executor(plugin_manager) -> Executor:
|
||||
pbar_class = plugin_manager.hook.get_progress_bar()
|
||||
return plugin_manager.hook.get_executor(pbar_class=pbar_class)
|
||||
pbar_class = plugin_manager.hook.get_progressbar_class()
|
||||
return plugin_manager.hook.get_executor(progressbar_class=pbar_class)
|
||||
|
||||
|
||||
class SerialExecutor(Executor):
|
||||
|
||||
@@ -726,7 +726,7 @@ def convert_to_pdfa(input_pdf: Path, input_ps_stub: Path, context: PdfContext):
|
||||
compression=options.pdfa_image_compression,
|
||||
pdfa_part=options.output_type[-1], # is pdfa-1, pdfa-2, or pdfa-3
|
||||
progressbar_class=(
|
||||
context.plugin_manager.hook.get_progress_bar()
|
||||
context.plugin_manager.hook.get_progressbar_class()
|
||||
if options.progress_bar
|
||||
else None
|
||||
),
|
||||
|
||||
@@ -155,12 +155,12 @@ class StandardExecutor(Executor):
|
||||
|
||||
|
||||
@hookimpl
|
||||
def get_executor():
|
||||
return StandardExecutor()
|
||||
def get_executor(progressbar_class):
|
||||
return StandardExecutor(pbar_class=progressbar_class)
|
||||
|
||||
|
||||
@hookimpl
|
||||
def get_progress_bar():
|
||||
def get_progressbar_class():
|
||||
return tqdm
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ hookspec = pluggy.HookspecMarker('ocrmypdf')
|
||||
# pylint: disable=unused-argument
|
||||
|
||||
|
||||
@hookspec
|
||||
@hookspec(firstresult=True)
|
||||
def get_logging_console() -> Handler:
|
||||
"""Returns a logging handler. Should be configured to handle progress bars."""
|
||||
|
||||
@@ -70,7 +70,7 @@ def check_options(options: Namespace) -> None:
|
||||
|
||||
|
||||
@hookspec(firstresult=True)
|
||||
def get_executor() -> Executor:
|
||||
def get_executor(progressbar_class) -> Executor:
|
||||
"""Called to obtain an object that manages parallel execution.
|
||||
|
||||
This may be used to replace OCRmyPDF's default parallel execution system
|
||||
@@ -92,7 +92,7 @@ def get_executor() -> Executor:
|
||||
|
||||
|
||||
@hookspec(firstresult=True)
|
||||
def get_progress_bar():
|
||||
def get_progressbar_class():
|
||||
"""Called to obtain a class that can be used to create progress bars.
|
||||
|
||||
The class should follow a tqdm-like protocol. Calling the class should return
|
||||
@@ -108,7 +108,7 @@ def get_progress_bar():
|
||||
Here is how OCRmyPDF will use the progress bar:
|
||||
|
||||
Example:
|
||||
pbar_class = pm.hook.get_progress_bar()
|
||||
pbar_class = pm.hook.get_progressbar_class()
|
||||
with pbar_class(**tqdm_kwargs) as pbar:
|
||||
...
|
||||
pbar.update(1)
|
||||
|
||||
Reference in New Issue
Block a user