Skipping out_path.mkdir step when processing paths in directories and per_page_targets isn't used
brprkr opened this issue · comments
Command (MacOS):
python3 -m remarks "/Users/../Library/Application Support/remarkable/desktop" ./exper-output/ --file_path zotero
Exception:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/Users/../Documents/temp/remarks/remarks/__main__.py", line 151, in <module>
main()
File "/Users/../Documents/temp/remarks/remarks/__main__.py", line 147, in main
run_remarks(input_dir, output_dir, **args_dict)
File "/Users/../Documents/temp/remarks/remarks/remarks.py", line 92, in run_remarks
process_document(metadata_path, out_path, doc_type, **kwargs)
File "/Users/../Documents/temp/remarks/remarks/remarks.py", line 432, in process_document
pdf_src.save(f"{out_doc_path_str} _remarks.pdf")
File "/Users/../Documents/temp/remarks/.venv/lib/python3.12/site-packages/fitz/__init__.py", line 5392, in save
mupdf.pdf_save_document(pdf, filename, opts)
File "/Users/../Documents/temp/remarks/.venv/lib/python3.12/site-packages/fitz/mupdf.py", line 50393, in pdf_save_document
return _mupdf.pdf_save_document(doc, filename, opts)
fitz.mupdf.FzErrorSystem: code=2: cannot open file 'exper-output-1/zotero/my_file.pdf _remarks.pdf': No such file or directory
Debug:
out_path.parent: exper-output/zotero
per_page_targets: []
has_ann: True
has_smart_hl: True
per_page_targets
being empty list means out_path.mkdir
isn't being executed. Addingout_path.mkdir
again before where files are saved avoids the exception. (If per_page_targets argument is required, I think this should be reported to the user instead of raising a file-related exception.)