From d4c97ebf7260eadf0e735255c5d86cd33ac61114 Mon Sep 17 00:00:00 2001 From: Konstantin Baierer Date: Thu, 15 Oct 2020 17:12:17 +0200 Subject: [PATCH] add OCR-D click interface --- sbb_binarize/ocrd_cli.py | 9 ++++++++- setup.py | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sbb_binarize/ocrd_cli.py b/sbb_binarize/ocrd_cli.py index 187269f..f4eac2c 100644 --- a/sbb_binarize/ocrd_cli.py +++ b/sbb_binarize/ocrd_cli.py @@ -4,15 +4,17 @@ import os.path from pkg_resources import resource_string from json import loads +from click import command from ocrd_utils import ( getLogger, assert_file_grp_cardinality, make_file_id, MIMETYPE_PAGE ) +from ocrd import Processor from ocrd_modelfactory import page_from_file from ocrd_models.ocrd_page import AlternativeImageType, to_xml -from ocrd import Processor +from ocrd.decorators import ocrd_cli_options, ocrd_cli_wrap_processor from .sbb_binarize import SbbBinarizer @@ -113,3 +115,8 @@ class SbbBinarizeProcessor(Processor): mimetype=MIMETYPE_PAGE, local_filename=os.path.join(self.output_file_grp, file_id + '.xml'), content=to_xml(pcgts)) + +@command() +@ocrd_cli_options +def cli(*args, **kwargs): + return ocrd_cli_wrap_processor(SbbBinarizeProcessor, *args, **kwargs) diff --git a/setup.py b/setup.py index 980dd2f..156f50d 100644 --- a/setup.py +++ b/setup.py @@ -23,6 +23,7 @@ setup( entry_points={ 'console_scripts': [ 'sbb_binarize=sbb_binarize.cli:main', + 'ocrd-sbb-binarize=sbb_binarize.ocrd_cli:cli', ] }, )