Make the go/no-go decision pluggable

This commit is contained in:
James R. Barlow
2019-06-06 23:07:46 -07:00
parent 5dd10c961c
commit 0bbd6885e2
4 changed files with 16 additions and 4 deletions
+6
View File
@@ -160,6 +160,12 @@ def validate_pdfinfo_options(context):
pdfinfo = context.pdfinfo
options = context.options
if options.plugin_validation:
validate = load_plugin(options.plugin_validation)
result = validate(context)
if result is not None:
return result
if pdfinfo.needs_rendering:
log.error(
"This PDF contains dynamic XFA forms created by Adobe LiveCycle "
+4 -1
View File
@@ -119,7 +119,9 @@ def create_options(*, input_file, output_file, **kwargs):
for arg, val in kwargs.items():
if val is None:
continue
if arg.startswith('filter') and (callable(val) or isinstance(val, str)):
if (arg.startswith('plugin') or arg.startswith('filter')) and (
callable(val) or isinstance(val, str)
):
deferred.append((arg, val))
continue
elif arg == 'tesseract_env':
@@ -199,6 +201,7 @@ def ocrmypdf( # pylint: disable=unused-argument
keep_temporary_files=None,
progress_bar=None,
filter_ocr_image=None,
plugin_validation=None,
tesseract_env=None,
):
"""Run OCRmyPDF on one PDF or image.
+5 -2
View File
@@ -468,10 +468,13 @@ advanced.add_argument(
help="Specify the location of the Tesseract user patterns file.",
)
filters = parser.add_argument_group("Filters", argparse.SUPPRESS)
filters.add_argument(
plugins = parser.add_argument_group("Filters and Plugins", argparse.SUPPRESS)
plugins.add_argument(
'--filter-ocr-image', help=argparse.SUPPRESS, type=check_plugin_loadable
)
plugins.add_argument(
'--plugin-validation', help=argparse.SUPPRESS, type=check_plugin_loadable
)
debugging = parser.add_argument_group(
"Debugging", "Arguments to help with troubleshooting and debugging"
+1 -1
View File
@@ -185,7 +185,7 @@ class LTStateAwareChar(LTChar):
def get_text(self):
if isinstance(self._text, tuple):
return ''
return '\ufffd' # standard 'Unknown symbol'
return self._text
def __repr__(self):