From 143acbe02eac490f8d89b08afe893afb9ed48743 Mon Sep 17 00:00:00 2001 From: Darryl Nixon Date: Sun, 16 Jul 2023 13:04:24 -0700 Subject: [PATCH] pathlib/aiopath compat fix for validation --- melamine/validators.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/melamine/validators.py b/melamine/validators.py index c300069..226d24d 100644 --- a/melamine/validators.py +++ b/melamine/validators.py @@ -1,20 +1,22 @@ import os import platform import sys -from pathlib import Path +from pathlib import Path as PathSync + +from aiopath import Path def validate_file_folder(value: str) -> Path: - file_folder_path = Path(value) + file_folder_path = PathSync(value) if not file_folder_path.exists(): raise FileNotFoundError(f"No such file or folder: {value}") if not file_folder_path.is_file() and not file_folder_path.is_dir(): raise TypeError(f"Not a file or directory: {value}") - return file_folder_path + return Path(value) def validate_logfile(value: str) -> Path: - logfile_path = Path(value) + logfile_path = PathSync(value) if logfile_path.exists(): confirm = input(f"The file {value} already exists. Do you want to overwrite it? ([y]es/[n]o): ") if confirm.lower() not in ["yes", "y"]: