Closed Jdogzz closed 2 months ago
Thanks for bringing this up. Yes, the input variable of the function pdf2bib needs to be a string in the current implementation. You are very welcome to submit a PR with your code.
Probably the simplest way would be to add a code similar to the one that you mentioned at the very beginning of the function, in order to convert a (potential) Pathlib object into a string.
Issue:
File type verification fails when using Pathlib to construct paths and passing that file to pdf2bib.
Expected behavior:
Providing a path to the file using Pathlib should work.
Actual behavior
The following error is thrown:
Minimal example to reproduce behavior
Additional info:
Here's a link to the line being considered:
https://github.com/MicheleCotrufo/pdf2bib/blob/f86a053cf9487f9fc9a2406e4bfe7acdb7f2629c/pdf2bib/main.py#L89
I'll be working on a workaround in my own code (probably just wrapping my path in
str
when passing it to pdf2bib), but it may be worth investigating whether a surgical change is due, like changing the above line toor if it would be worthwhile to use Pathlib instead of os.path in the pdf2bib project. In that case, there are calls like this that could be used when doing the check (although still requiring a lowercase string comparison like in your current code):
https://docs.python.org/3/library/pathlib.html#pathlib.PurePath.suffix