From 50aaf6531fdec51179afa746f0e97f4e5676aa15 Mon Sep 17 00:00:00 2001 From: Jdogzz Date: Mon, 17 Jun 2024 05:54:00 -0700 Subject: [PATCH 1/2] Verify that path is string Adds conversion of path to string. --- pdf2doi/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pdf2doi/main.py b/pdf2doi/main.py index 98471f0..b5bf31d 100644 --- a/pdf2doi/main.py +++ b/pdf2doi/main.py @@ -46,6 +46,9 @@ def pdf2doi(target): logger = logging.getLogger("pdf2doi") + # Make sure the path is a string in case a Pathlib object is provided + target = str(target) + # Check if path is valid if not (path.exists(target)): logger.error(f"{target} is not a valid path to a file or a directory.") @@ -379,4 +382,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() From 8cd3a2d2b827df5f0ee915672435efff191febd4 Mon Sep 17 00:00:00 2001 From: Jdogzz Date: Mon, 17 Jun 2024 05:55:20 -0700 Subject: [PATCH 2/2] Verify if path is string Add another check to make sure path is a string. --- pdf2doi/finders.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pdf2doi/finders.py b/pdf2doi/finders.py index bcd979b..e34f2e1 100644 --- a/pdf2doi/finders.py +++ b/pdf2doi/finders.py @@ -601,6 +601,10 @@ def add_found_identifier_to_metadata(target,identifier): ------- True if the the metadata was added succesfully, false otherwise """ + + # Make sure the path is a string in case a Pathlib object is provided + target = str(target) + add_metadata(target,key='/pdf2doi_identifier',value=identifier)