Migration Guide for Version 0.2
February 20, 2025Less than 1 minute
V0.2.0 Breaking Changes
Return Parameter Updates
The version parameter has been removed, and the return value is now a tuple containing three elements (list1, list2, bool), in the same order as the input files:
list1(list): List of successfully processed file paths- Elements are the paths of processed files (strings)
- Empty string if processing failed
list2(list): List of files that failed to process- Elements are dictionaries containing two keys:
'error': Error message (string)'path': Path of the file that failed to process (string)
- Both keys' values are empty strings if processing succeeded
- Elements are dictionaries containing two keys:
bool: Processing statusTrue: At least one file failed to processFalse: All files processed successfully
How to Minimize Changes to Adapt to the Update
If your old version code did not use the version parameter, for example:
from pdfdeal.doc2x import Doc2X
client = Doc2X()
filepath = client.pdf2file(
"tests/pdf/sample.pdf", output_names=["Test.zip"], output_format="latex"
)
print(filepath)The return values of all functions have changed to three values in the new version, (list1, list2, bool). You only need to change line 4:
from pdfdeal.doc2x import Doc2X
client = Doc2X()
filepath, failed, flag = client.pdf2file(
"tests/pdf/sample.pdf", output_names=["Test.zip"], output_format="latex"
)
print(filepath)If your code used the version="v2" parameter, for example:
from pdfdeal.doc2x import Doc2X
from pdfdeal import get_files
client = Doc2X()
file_list, rename_list = get_files(
path="./tests/pdf", mode="pdf", out="docx"
)
success, failed, flag = client.pdf2file(
pdf_file=file_list,
output_path="./Output/newfolder",
output_names=rename_list,
output_format="docx",
version="v2",
)
print(success)
print(failed)
print(flag)You only need to remove version="v2",:
from pdfdeal.doc2x import Doc2X
from pdfdeal import get_files
client = Doc2X()
file_list, rename_list = get_files(
path="./tests/pdf", mode="pdf", out="docx"
)
success, failed, flag = client.pdf2file(
pdf_file=file_list,
output_path="./Output/newfolder",
output_names=rename_list,
output_format="docx",
)
print(success)
print(failed)
print(flag)