pathlib/aiopath compat fix for validation

This commit is contained in:
Darryl Nixon 2023-07-16 13:04:24 -07:00
parent ffbf73a372
commit 143acbe02e

View file

@ -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"]: