mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-06-12 19:55:17 +02:00
feat(filesystem): support space-separated cat node ids
This commit is contained in:
parent
4a158f9e5f
commit
2b69719f60
2 changed files with 17 additions and 5 deletions
|
|
@ -517,7 +517,10 @@ class PIFSCommandExecutor:
|
|||
if i >= len(args):
|
||||
raise PIFSCommandError("cat --node requires a node id")
|
||||
structural_mode = "node"
|
||||
node_ids.extend(self._parse_node_ids(args[i]))
|
||||
while i < len(args) and not args[i].startswith("-"):
|
||||
node_ids.extend(self._parse_node_ids(args[i]))
|
||||
i += 1
|
||||
i -= 1
|
||||
elif arg == "--page":
|
||||
i += 1
|
||||
if i >= len(args):
|
||||
|
|
@ -528,8 +531,10 @@ class PIFSCommandExecutor:
|
|||
raise PIFSCommandError(f"Unsupported cat option: {arg}")
|
||||
else:
|
||||
raise PIFSCommandError(
|
||||
"cat accepts one file target. Use: cat <path|file_ref|document_id> --page <page-or-range>, "
|
||||
"for example: cat /documents/report.pdf --page 31-59"
|
||||
"cat accepts one file target. Use target-first syntax: "
|
||||
"cat <path|file_ref|document_id> --structure, "
|
||||
"cat <path|file_ref|document_id> --node 0002 0004, or "
|
||||
"cat <path|file_ref|document_id> --page 31-33"
|
||||
)
|
||||
i += 1
|
||||
if structural_mode == "structure":
|
||||
|
|
|
|||
|
|
@ -481,11 +481,18 @@ def test_cat_structure_page_node_and_text_outputs_are_hard_limited():
|
|||
executor.execute("cat dsid_limited_pdf --page 1-4")
|
||||
|
||||
nodes = json.loads(
|
||||
executor.execute("cat dsid_limited_pdf --node 0001,0002,0003,0004,0005")
|
||||
executor.execute("cat dsid_limited_pdf --node 0001 0002 0003 0004 0005")
|
||||
)
|
||||
assert nodes["data"]["node_ids"] == ["0001", "0002", "0003", "0004", "0005"]
|
||||
comma_nodes = json.loads(
|
||||
executor.execute("cat dsid_limited_pdf --node 0001,0002")
|
||||
)
|
||||
assert comma_nodes["data"]["node_ids"] == ["0001", "0002"]
|
||||
with pytest.raises(PIFSCommandError, match="at most 5"):
|
||||
executor.execute("cat dsid_limited_pdf --node 0001,0002,0003,0004,0005,0006")
|
||||
executor.execute("cat dsid_limited_pdf --node 0001 0002 0003 0004 0005 0006")
|
||||
|
||||
with pytest.raises(PIFSCommandError, match="cat accepts one file target"):
|
||||
executor.execute("cat dsid_limited_pdf 0001")
|
||||
|
||||
text = json.loads(executor.execute("cat dsid_long_text --all"))
|
||||
assert "line 100" in text["data"]["text"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue