From 38dc0ca5125ef31fd056649d6ea4f9d544b71c6b Mon Sep 17 00:00:00 2001 From: cegea Date: Tue, 17 Sep 2024 13:49:09 +0200 Subject: [PATCH] Add support for upper case extension file PDFs --- src/pdf_watermark/options.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pdf_watermark/options.py b/src/pdf_watermark/options.py index 7a7d9e0..d35a332 100644 --- a/src/pdf_watermark/options.py +++ b/src/pdf_watermark/options.py @@ -53,12 +53,12 @@ def __init__( if not os.path.exists(input): raise ValueError("Input file or directory does not exist.") elif os.path.isdir(input): - if output is not None and output.endswith(".pdf"): + if output is not None and output.endswith((".pdf", ".PDF")): raise ValueError( "Output must be a directory when input is a directory." ) - elif os.path.isfile(input) and input.endswith(".pdf"): - if output is not None and not output.endswith(".pdf"): + elif os.path.isfile(input) and input.endswith((".pdf", ".PDF")): + if output is not None and not output.endswith((".pdf", ".PDF")): raise ValueError("Output must be a pdf file when input is a pdf file.") else: raise ValueError("Input must be a pdf file or a directory.") @@ -92,7 +92,7 @@ def add_directory_to_files( if os.path.isdir(input_path): self.add_directory_to_files(input_path, output_path) - elif os.path.isfile(input_path) and input_path.endswith(".pdf"): + elif os.path.isfile(input_path) and input_path.endswith((".pdf", ".PDF")): self.input_files.append(input_path) self.output_files.append(output_path)