code: def _valid_pdf(self, path, filename):
          
          # If path is file, but not PDF.
          if os.path.isfile(path) and path.lower().endswith(".pdf"):
              return True
          else:
              full_path = os.path.join(path, filename)
              if os.path.isfile(full_path) and full_path.lower().endswith(".pdf"):
                  return True
              elif os.path.isfile(os.path.join(path, filename + ".pdf")):
                  return True
              elif os.path.isfile(os.path.join(path, filename + ".PDF")):
                  return True
  
          return False
docs: Verify that the file exists and has a PDF extension.