Commit 88f2245d authored by 赵小蒙's avatar 赵小蒙

update cli

parent bc055266
...@@ -27,6 +27,7 @@ import sys ...@@ -27,6 +27,7 @@ import sys
import click import click
from loguru import logger from loguru import logger
from pathlib import Path from pathlib import Path
from magic_pdf.libs.version import __version__
from magic_pdf.libs.MakeContentConfig import DropMode from magic_pdf.libs.MakeContentConfig import DropMode
from magic_pdf.libs.draw_bbox import draw_layout_bbox, draw_span_bbox from magic_pdf.libs.draw_bbox import draw_layout_bbox, draw_span_bbox
...@@ -52,7 +53,7 @@ def prepare_env(pdf_file_name, method): ...@@ -52,7 +53,7 @@ def prepare_env(pdf_file_name, method):
get_local_dir(), "magic-pdf", pdf_file_name, method get_local_dir(), "magic-pdf", pdf_file_name, method
) )
local_image_dir = os.path.join(local_parent_dir, "images") local_image_dir = os.path.join(str(local_parent_dir), "images")
local_md_dir = local_parent_dir local_md_dir = local_parent_dir
os.makedirs(local_image_dir, exist_ok=True) os.makedirs(local_image_dir, exist_ok=True)
os.makedirs(local_md_dir, exist_ok=True) os.makedirs(local_md_dir, exist_ok=True)
...@@ -102,6 +103,7 @@ def cli(): ...@@ -102,6 +103,7 @@ def cli():
@cli.command() @cli.command()
@click.version_option(__version__, "--version", "-v", help="显示版本信息")
@click.option("--json", type=str, help="输入一个S3路径") @click.option("--json", type=str, help="输入一个S3路径")
@click.option( @click.option(
"--method", "--method",
...@@ -158,15 +160,16 @@ def json_command(json, method): ...@@ -158,15 +160,16 @@ def json_command(json, method):
) )
@cli.command() @cli.command()
@click.option("--local_json", type=str, help="输入一个本地jsonl路径") @click.version_option(__version__, "--version", "-v", help="显示版本信息")
@click.option( @click.option("--local_json", type=str, help="输入一个本地jsonl路径")
@click.option(
"--method", "--method",
type=parse_pdf_methods, type=parse_pdf_methods,
help="指定解析方法。txt: 文本型 pdf 解析方法, ocr: 光学识别解析 pdf, auto: 程序智能选择解析方法", help="指定解析方法。txt: 文本型 pdf 解析方法, ocr: 光学识别解析 pdf, auto: 程序智能选择解析方法",
default="auto", default="auto",
) )
def local_json_command(local_json, method): def local_json_command(local_json, method):
def read_s3_path(s3path): def read_s3_path(s3path):
bucket, key = parse_s3path(s3path) bucket, key = parse_s3path(s3path)
...@@ -215,6 +218,7 @@ def json_command(json, method): ...@@ -215,6 +218,7 @@ def json_command(json, method):
@cli.command() @cli.command()
@click.version_option(__version__, "--version", "-v", help="显示版本信息")
@click.option( @click.option(
"--pdf", type=click.Path(exists=True), required=True, help="PDF文件的路径" "--pdf", type=click.Path(exists=True), required=True, help="PDF文件的路径"
) )
...@@ -256,6 +260,7 @@ def pdf_command(pdf, model, method): ...@@ -256,6 +260,7 @@ def pdf_command(pdf, model, method):
) )
if __name__ == "__main__": if __name__ == "__main__":
""" """
python magic_pdf/cli/magicpdf.py json-command --json s3://llm-pdf-text/pdf_ebook_and_paper/manual/v001/part-660407a28beb-000002.jsonl?bytes=0,63551 python magic_pdf/cli/magicpdf.py json-command --json s3://llm-pdf-text/pdf_ebook_and_paper/manual/v001/part-660407a28beb-000002.jsonl?bytes=0,63551
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment