mirror of
https://github.com/DarrylNixon/melamine.git
synced 2024-04-22 06:27:20 -07:00
pathlib/aiopath compat fix for validation
This commit is contained in:
parent
ffbf73a372
commit
143acbe02e
1 changed files with 6 additions and 4 deletions
|
@ -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"]:
|
||||
|
|
Loading…
Reference in a new issue