🎨 reformat cli.py with black

pull/8/head
Konstantin Baierer 3 years ago
parent ec553a2060
commit 3dda276a13

@ -0,0 +1,2 @@
pytest
black

@ -1,21 +1,101 @@
import click
from sbb_newspapers_org_image.eynollah import eynollah
@click.command()
@click.option("--image", "-i", help="image filename", type=click.Path(exists=True, dir_okay=False))
@click.option("--out", "-o", help="directory to write output xml data", type=click.Path(exists=True, file_okay=False))
@click.option("--model", "-m", help="directory of models", type=click.Path(exists=True, file_okay=False))
@click.option("--save_images", "-si", help="if a directory is given, images in documents will be cropped and saved there", type=click.Path(exists=True, file_okay=False))
@click.option("--save_layout", "-sl", help="if a directory is given, plot of layout will be saved there", type=click.Path(exists=True, file_okay=False))
@click.option("--save_deskewed", "-sd", help="if a directory is given, deskewed image will be saved there", type=click.Path(exists=True, file_okay=False))
@click.option("--save_all", "-sa", help="if a directory is given, all plots needed for documentation will be saved there", type=click.Path(exists=True, file_okay=False))
@click.option("--allow_enhancement", "-ae", help="if this parameter set to true, this tool would check that input image need resizing and enhancement or not. If so output of resized and enhanced image and corresponding layout data will be written in out directory")
@click.option("--curved_line", "-cl", help="if this parameter set to true, this tool will try to return contoure of textlines instead of rectabgle bounding box of textline. This should be taken into account that with this option the tool need more time to do process.")
@click.option("--full_layout", "-fl", help="if this parameter set to true, this tool will try to return all elements of layout.")
@click.option("--allow_scaling", "-as", help="if this parameter set to true, this tool would check the scale and if needed it will scale it to perform better layout detection")
@click.option("--headers_off", "-ho", help="if this parameter set to true, this tool would ignore headers role in reading order")
def main(image, out, model, save_images, save_layout, save_deskewed, save_all, allow_enhancement, curved_line, full_layout, allow_scaling, headers_off):
x = eynollah(image, None, out, model, save_images, save_layout, save_deskewed, save_all, allow_enhancement, curved_line, full_layout, allow_scaling, headers_off)
@click.option(
"--image", "-i", help="image filename", type=click.Path(exists=True, dir_okay=False)
)
@click.option(
"--out",
"-o",
help="directory to write output xml data",
type=click.Path(exists=True, file_okay=False),
)
@click.option(
"--model",
"-m",
help="directory of models",
type=click.Path(exists=True, file_okay=False),
)
@click.option(
"--save_images",
"-si",
help="if a directory is given, images in documents will be cropped and saved there",
type=click.Path(exists=True, file_okay=False),
)
@click.option(
"--save_layout",
"-sl",
help="if a directory is given, plot of layout will be saved there",
type=click.Path(exists=True, file_okay=False),
)
@click.option(
"--save_deskewed",
"-sd",
help="if a directory is given, deskewed image will be saved there",
type=click.Path(exists=True, file_okay=False),
)
@click.option(
"--save_all",
"-sa",
help="if a directory is given, all plots needed for documentation will be saved there",
type=click.Path(exists=True, file_okay=False),
)
@click.option(
"--allow_enhancement",
"-ae",
help="if this parameter set to true, this tool would check that input image need resizing and enhancement or not. If so output of resized and enhanced image and corresponding layout data will be written in out directory",
)
@click.option(
"--curved_line",
"-cl",
help="if this parameter set to true, this tool will try to return contoure of textlines instead of rectabgle bounding box of textline. This should be taken into account that with this option the tool need more time to do process.",
)
@click.option(
"--full_layout",
"-fl",
help="if this parameter set to true, this tool will try to return all elements of layout.",
)
@click.option(
"--allow_scaling",
"-as",
help="if this parameter set to true, this tool would check the scale and if needed it will scale it to perform better layout detection",
)
@click.option(
"--headers_off",
"-ho",
help="if this parameter set to true, this tool would ignore headers role in reading order",
)
def main(
image,
out,
model,
save_images,
save_layout,
save_deskewed,
save_all,
allow_enhancement,
curved_line,
full_layout,
allow_scaling,
headers_off,
):
x = eynollah(
image,
None,
out,
model,
save_images,
save_layout,
save_deskewed,
save_all,
allow_enhancement,
curved_line,
full_layout,
allow_scaling,
headers_off,
)
x.run()

@ -39,7 +39,22 @@ from .utils import filter_contours_area_of_image_tables
class eynollah:
def __init__(self, image_dir, f_name, dir_out, dir_models, dir_of_cropped_images=None, dir_of_layout=None, dir_of_deskewed=None, dir_of_all=None, allow_enhancement="false", curved_line="false", full_layout="false", allow_scaling="false", headers_off="false"):
def __init__(
self,
image_dir,
f_name,
dir_out,
dir_models,
dir_of_cropped_images=None,
dir_of_layout=None,
dir_of_deskewed=None,
dir_of_all=None,
allow_enhancement="false",
curved_line="false",
full_layout="false",
allow_scaling="false",
headers_off="false"
):
self.image_dir = image_dir # XXX This does not seem to be a directory as the name suggests, but a file
self.dir_out = dir_out
self.f_name = f_name

Loading…
Cancel
Save