"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/ocrmypdf/__main__.py" between
OCRmyPDF-8.0.1.tar.gz and OCRmyPDF-8.1.0.tar.gz

About: OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be searched.

__main__.py  (OCRmyPDF-8.0.1):__main__.py  (OCRmyPDF-8.1.0)
skipping to change at line 278 skipping to change at line 278
"the output", "the output",
) )
preprocessing.add_argument( preprocessing.add_argument(
'-i', '-i',
'--clean-final', '--clean-final',
action='store_true', action='store_true',
help="Clean page as above, and incorporate the cleaned image in the final " help="Clean page as above, and incorporate the cleaned image in the final "
"PDF. Might remove desired content.", "PDF. Might remove desired content.",
) )
preprocessing.add_argument( preprocessing.add_argument(
'--unpaper-args',
type=str,
default=None,
help="A quoted string of arguments to pass to unpaper. Requires --clean. "
"Example: --unpaper-args '--layout double'.",
)
preprocessing.add_argument(
'--oversample', '--oversample',
metavar='DPI', metavar='DPI',
type=numeric(int, 0, 5000), type=numeric(int, 0, 5000),
default=0, default=0,
help="Oversample images to at least the specified DPI, to improve OCR " help="Oversample images to at least the specified DPI, to improve OCR "
"results slightly", "results slightly",
) )
preprocessing.add_argument( preprocessing.add_argument(
'--remove-vectors', '--remove-vectors',
action='store_true', action='store_true',
skipping to change at line 616 skipping to change at line 623
f"The installed '{name}' is not supported. " f"The installed '{name}' is not supported. "
f"Install version {min_version} or newer." f"Install version {min_version} or newer."
) )
except (FileNotFoundError, MissingDependencyError): except (FileNotFoundError, MissingDependencyError):
complain( complain(
f"For best results, install the optional program '{name}' to use the " f"For best results, install the optional program '{name}' to use the "
f"argument {for_argument}." f"argument {for_argument}."
) )
def check_options_preprocessing(options, log): def check_options_preprocessing(options, log):
if options.clean_final:
options.clean = True
if options.unpaper_args and not options.clean:
raise argparse.ArgumentError(
None, "--clean is required for --unpaper-args"
)
if any((options.clean, options.clean_final)): if any((options.clean, options.clean_final)):
from .exec import unpaper from .exec import unpaper
_optional_program_required( _optional_program_required(
'unpaper', unpaper.version, '6.1', '--clean, --clean-final' 'unpaper', unpaper.version, '6.1', '--clean, --clean-final'
) )
try:
if options.unpaper_args:
options.unpaper_args = unpaper.validate_custom_args(
options.unpaper_args
)
except Exception as e:
raise argparse.ArgumentError(None, str(e))
def check_options_ocr_behavior(options, log): def check_options_ocr_behavior(options, log):
exclusive_options = sum( exclusive_options = sum(
[ [
(1 if opt else 0) (1 if opt else 0)
for opt in (options.force_ocr, options.skip_text, options.redo_ocr) for opt in (options.force_ocr, options.skip_text, options.redo_ocr)
] ]
) )
if exclusive_options >= 2: if exclusive_options >= 2:
raise argparse.ArgumentError( raise argparse.ArgumentError(
skipping to change at line 1055 skipping to change at line 1075
manager = JobContextManager() manager = JobContextManager()
manager.register('JobContext', JobContext) # pylint: disable=no-member manager.register('JobContext', JobContext) # pylint: disable=no-member
manager.start() manager.start()
context = manager.JobContext() # pylint: disable=no-member context = manager.JobContext() # pylint: disable=no-member
context.set_options(options) context.set_options(options)
context.set_work_folder(work_folder) context.set_work_folder(work_folder)
build_pipeline(options, work_folder, _log, context) build_pipeline(options, work_folder, _log, context)
atexit.register(cleanup_working_files, work_folder, options) atexit.register(cleanup_working_files, work_folder, options)
if hasattr(os, 'nice'):
os.nice(5)
cmdline.run(options) cmdline.run(options)
except ruffus_exceptions.RethrownJobError as e: except ruffus_exceptions.RethrownJobError as e:
if options.verbose: if options.verbose:
_log.debug(str(e)) # stringify exception so logger doesn't have to _log.debug(str(e)) # stringify exception so logger doesn't have to
exceptions = e.job_exceptions exceptions = e.job_exceptions
exitcode = traverse_ruffus_exception(exceptions, options, _log) exitcode = traverse_ruffus_exception(exceptions, options, _log)
if exitcode is None: if exitcode is None:
_log.error("Unexpected ruffus exception: " + str(e)) _log.error("Unexpected ruffus exception: " + str(e))
_log.error(repr(e)) _log.error(repr(e))
return ExitCode.other_error return ExitCode.other_error
 End of changes. 4 change blocks. 
0 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)