licos-dev-cli 0.4.3__tar.gz → 0.4.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {licos_dev_cli-0.4.3 → licos_dev_cli-0.4.4}/PKG-INFO +2 -2
- {licos_dev_cli-0.4.3 → licos_dev_cli-0.4.4}/pyproject.toml +2 -2
- {licos_dev_cli-0.4.3 → licos_dev_cli-0.4.4}/src/licos_dev_cli/docx_commands.py +26 -5
- {licos_dev_cli-0.4.3 → licos_dev_cli-0.4.4}/tests/test_docx_commands.py +17 -1
- {licos_dev_cli-0.4.3 → licos_dev_cli-0.4.4}/.gitignore +0 -0
- {licos_dev_cli-0.4.3 → licos_dev_cli-0.4.4}/src/licos_dev_cli/__init__.py +0 -0
- {licos_dev_cli-0.4.3 → licos_dev_cli-0.4.4}/src/licos_dev_cli/common.py +0 -0
- {licos_dev_cli-0.4.3 → licos_dev_cli-0.4.4}/src/licos_dev_cli/docx_legacy.py +0 -0
- {licos_dev_cli-0.4.3 → licos_dev_cli-0.4.4}/src/licos_dev_cli/main.py +0 -0
- {licos_dev_cli-0.4.3 → licos_dev_cli-0.4.4}/src/licos_dev_cli/ppt_master.py +0 -0
- {licos_dev_cli-0.4.3 → licos_dev_cli-0.4.4}/tests/test_cli_output_paths.py +0 -0
- {licos_dev_cli-0.4.3 → licos_dev_cli-0.4.4}/tests/test_credit_check.py +0 -0
- {licos_dev_cli-0.4.3 → licos_dev_cli-0.4.4}/tests/test_document_read_cli.py +0 -0
- {licos_dev_cli-0.4.3 → licos_dev_cli-0.4.4}/tests/test_ppt_master_cli.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: licos-dev-cli
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.4
|
|
4
4
|
Summary: LICOS Dev CLI - generate files and call model capabilities
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Requires-Dist: click>=8.1
|
|
7
|
-
Requires-Dist: licos-dev-sdk>=0.4.
|
|
7
|
+
Requires-Dist: licos-dev-sdk>=0.4.4
|
|
@@ -4,11 +4,11 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "licos-dev-cli"
|
|
7
|
-
version = "0.4.
|
|
7
|
+
version = "0.4.4"
|
|
8
8
|
description = "LICOS Dev CLI - generate files and call model capabilities"
|
|
9
9
|
requires-python = ">=3.10"
|
|
10
10
|
dependencies = [
|
|
11
|
-
"licos-dev-sdk>=0.4.
|
|
11
|
+
"licos-dev-sdk>=0.4.4",
|
|
12
12
|
"click>=8.1",
|
|
13
13
|
]
|
|
14
14
|
|
|
@@ -70,6 +70,21 @@ def docx_structure(**arguments):
|
|
|
70
70
|
result(read_docx_structure(**arguments))
|
|
71
71
|
|
|
72
72
|
|
|
73
|
+
@click.command("docx-inspect")
|
|
74
|
+
@click.option("--file", "source", required=True, type=click.Path(exists=True, dir_okay=False))
|
|
75
|
+
@click.option("--scope", type=click.Choice(["all", "fields", "images", "tables"]), default="all", show_default=True)
|
|
76
|
+
@click.option("--offset", type=click.IntRange(min=1), default=1, show_default=True)
|
|
77
|
+
@click.option("--limit", type=click.IntRange(1, 200), default=20, show_default=True)
|
|
78
|
+
@sdk_errors
|
|
79
|
+
def docx_inspect(**arguments):
|
|
80
|
+
"""Inspect native TOC fields, embedded/linked images and tables, including headers/footers.
|
|
81
|
+
|
|
82
|
+
Reports field update settings, not rendered pages. Continue each scope with next_offset.
|
|
83
|
+
"""
|
|
84
|
+
from licos_dev_sdk import inspect_docx
|
|
85
|
+
result(inspect_docx(**arguments))
|
|
86
|
+
|
|
87
|
+
|
|
73
88
|
@click.command("docx-target")
|
|
74
89
|
@click.option("--file", "source", required=True, type=click.Path(exists=True, dir_okay=False))
|
|
75
90
|
@target_options
|
|
@@ -155,7 +170,7 @@ def docx_table_insert_rows(input_path, **arguments):
|
|
|
155
170
|
@click.command("docx-verify")
|
|
156
171
|
@click.option("--file", "source", required=True, type=click.Path(exists=True, dir_okay=False))
|
|
157
172
|
@click.option("--original", type=click.Path(exists=True, dir_okay=False), help="Compare non-body package parts (headers, footers, styles, images) and section settings with the original.")
|
|
158
|
-
@click.option("--input", "input_path", type=click.Path(exists=True, dir_okay=False), help="JSON array of
|
|
173
|
+
@click.option("--input", "input_path", type=click.Path(exists=True, dir_okay=False), help="JSON array: target, exactly one of text/text_file, optional mode. Relative text_file paths use the JSON file's directory.")
|
|
159
174
|
@target_options
|
|
160
175
|
@click.option("--text", default=None, help="Expected text at one target; use this or --text-file instead of --input.")
|
|
161
176
|
@click.option("--text-file", type=click.Path(exists=True, dir_okay=False), help="UTF-8 expected text; preserves whitespace and line breaks.")
|
|
@@ -164,7 +179,7 @@ def docx_table_insert_rows(input_path, **arguments):
|
|
|
164
179
|
def docx_verify(source, original, input_path, paragraph, block, table, row, column, text, text_file, mode):
|
|
165
180
|
"""Verify exact positions and optional original parts. No assertions means no content verification.
|
|
166
181
|
|
|
167
|
-
Example: [{"target":{"
|
|
182
|
+
Example: [{"target":{"block":3},"text_file":"expected.txt","mode":"equals"}]
|
|
168
183
|
|
|
169
184
|
Exits 2 if an assertion or original comparison fails. Does not certify rendered page layout.
|
|
170
185
|
"""
|
|
@@ -175,8 +190,14 @@ def docx_verify(source, original, input_path, paragraph, block, table, row, colu
|
|
|
175
190
|
raise click.UsageError("use --input or a single target with --text/--text-file, not both")
|
|
176
191
|
expectations = json.loads(Path(input_path).read_text(encoding="utf-8")) if input_path else None
|
|
177
192
|
if single:
|
|
178
|
-
|
|
179
|
-
|
|
193
|
+
expectation = {"target": position, "mode": mode or "equals"}
|
|
194
|
+
if text is not None:
|
|
195
|
+
expectation["text"] = text
|
|
196
|
+
if text_file is not None:
|
|
197
|
+
expectation["text_file"] = text_file
|
|
198
|
+
expectations = [expectation]
|
|
199
|
+
report = verify_docx(source, original=original, expectations=expectations,
|
|
200
|
+
base_dir=Path(input_path).resolve().parent if input_path else Path.cwd())
|
|
180
201
|
result(report)
|
|
181
202
|
if not report["verified"]:
|
|
182
203
|
raise click.exceptions.Exit(2)
|
|
@@ -184,4 +205,4 @@ def docx_verify(source, original, input_path, paragraph, block, table, row, colu
|
|
|
184
205
|
|
|
185
206
|
DOCX_COMMANDS = [docx, docx_template, docx_edit, docx_read, docx_structure, docx_target,
|
|
186
207
|
docx_replace, docx_delete_blocks, docx_edit_structure, docx_table_set,
|
|
187
|
-
docx_table_insert_rows, docx_verify]
|
|
208
|
+
docx_table_insert_rows, docx_verify, docx_inspect]
|
|
@@ -24,6 +24,22 @@ def invoke(*arguments):
|
|
|
24
24
|
return json.loads(result.output)
|
|
25
25
|
|
|
26
26
|
|
|
27
|
+
def test_inspect_and_file_assertions_use_cli_contract(source, tmp_path, monkeypatch):
|
|
28
|
+
report = invoke("docx-inspect", "--file", source)
|
|
29
|
+
assert report["table_count"] == 1 and report["image_count"] == 0
|
|
30
|
+
folder = tmp_path / "checks"
|
|
31
|
+
folder.mkdir()
|
|
32
|
+
expected = folder / "expected.txt"
|
|
33
|
+
expected.write_text("账号:123", encoding="utf-8")
|
|
34
|
+
checks = folder / "assertions.json"
|
|
35
|
+
checks.write_text(json.dumps([{"target": {"block": 1}, "text_file": "expected.txt"}]), encoding="utf-8")
|
|
36
|
+
monkeypatch.chdir(tmp_path)
|
|
37
|
+
assert invoke("docx-verify", "--file", source, "--input", checks)["verified"]
|
|
38
|
+
assert invoke("docx-verify", "--file", source, "--block", 1, "--text-file", "checks/expected.txt")["verified"]
|
|
39
|
+
invalid = CliRunner().invoke(cli, ["docx-verify", "--file", str(source), "--block", "1", "--text", "x", "--text-file", str(expected)])
|
|
40
|
+
assert invalid.exit_code != 0 and "exactly one" in invalid.output
|
|
41
|
+
|
|
42
|
+
|
|
27
43
|
def test_focused_commands_complete_read_replace_delete_and_verify(source, tmp_path):
|
|
28
44
|
read = invoke("docx-structure", "--file", source)
|
|
29
45
|
output = tmp_path / "filled.docx"
|
|
@@ -75,7 +91,7 @@ def test_bad_revision_reports_original_error_and_leaves_output_absent(source, tm
|
|
|
75
91
|
def test_command_help_is_focused_and_preserves_constraints():
|
|
76
92
|
runner = CliRunner()
|
|
77
93
|
for name in ("docx-structure", "docx-target", "docx-replace", "docx-delete-blocks", "docx-edit-structure",
|
|
78
|
-
"docx-table-set", "docx-table-insert-rows", "docx-verify"):
|
|
94
|
+
"docx-table-set", "docx-table-insert-rows", "docx-verify", "docx-inspect"):
|
|
79
95
|
help_text = runner.invoke(cli, [name, "--help"])
|
|
80
96
|
assert help_text.exit_code == 0
|
|
81
97
|
assert len(help_text.output.encode("utf-8")) < 5000
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|