Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
MinerU
Commits
b943f04e
"docs/vscode:/vscode.git/clone" did not exist on "d579d4b293bdcafb08aa6422a529d4eaa39a9af8"
Commit
b943f04e
authored
Jul 04, 2025
by
myhloli
Browse files
refactor: enhance argument parsing in main function to support additional keyword arguments
parent
9a3a3149
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
1 deletion
+40
-1
mineru/cli/client.py
mineru/cli/client.py
+40
-1
No files found.
mineru/cli/client.py
View file @
b943f04e
...
...
@@ -10,6 +10,7 @@ from ..version import __version__
from
.common
import
do_parse
,
read_fn
,
pdf_suffixes
,
image_suffixes
@
click
.
command
(
context_settings
=
dict
(
ignore_unknown_options
=
True
,
allow_extra_args
=
True
))
@
click
.
pass_context
@
click
.
version_option
(
__version__
,
'--version'
,
'-v'
,
...
...
@@ -138,11 +139,49 @@ from .common import do_parse, read_fn, pdf_suffixes, image_suffixes
def
main
(
ctx
,
input_path
,
output_dir
,
method
,
backend
,
lang
,
server_url
,
start_page_id
,
end_page_id
,
formula_enable
,
table_enable
,
device_mode
,
virtual_vram
,
model_source
,
**
kwargs
):
# 解析额外参数
extra_kwargs
=
{}
i
=
0
while
i
<
len
(
ctx
.
args
):
arg
=
ctx
.
args
[
i
]
if
arg
.
startswith
(
'--'
):
param_name
=
arg
[
2
:].
replace
(
'-'
,
'_'
)
# 转换参数名格式
i
+=
1
if
i
<
len
(
ctx
.
args
)
and
not
ctx
.
args
[
i
].
startswith
(
'--'
):
# 参数有值
try
:
# 尝试转换为适当的类型
if
ctx
.
args
[
i
].
lower
()
==
'true'
:
extra_kwargs
[
param_name
]
=
True
elif
ctx
.
args
[
i
].
lower
()
==
'false'
:
extra_kwargs
[
param_name
]
=
False
elif
'.'
in
ctx
.
args
[
i
]:
try
:
extra_kwargs
[
param_name
]
=
float
(
ctx
.
args
[
i
])
except
ValueError
:
extra_kwargs
[
param_name
]
=
ctx
.
args
[
i
]
else
:
try
:
extra_kwargs
[
param_name
]
=
int
(
ctx
.
args
[
i
])
except
ValueError
:
extra_kwargs
[
param_name
]
=
ctx
.
args
[
i
]
except
:
extra_kwargs
[
param_name
]
=
ctx
.
args
[
i
]
else
:
# 布尔型标志参数
extra_kwargs
[
param_name
]
=
True
i
-=
1
i
+=
1
# 将解析出的参数合并到kwargs
kwargs
.
update
(
extra_kwargs
)
if
not
backend
.
endswith
(
'-client'
):
def
get_device_mode
()
->
str
:
if
device_mode
is
not
None
:
...
...
@@ -188,7 +227,7 @@ def main(
table_enable
=
table_enable
,
server_url
=
server_url
,
start_page_id
=
start_page_id
,
end_page_id
=
end_page_id
end_page_id
=
end_page_id
,
**
kwargs
,
)
except
Exception
as
e
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment