2025-03-02 23:51:53 +00:00

18 lines
499 B
Python

from argparse import ArgumentTypeError
import os
def get_full_path(relative_path):
if not os.path.isabs(relative_path):
current_dir = os.getcwd()
full_path = os.path.join(current_dir, relative_path)
else:
full_path = relative_path
return full_path
def dir_arg_type(path):
full_path = get_full_path(path)
if os.path.isdir(full_path):
return full_path
else:
raise ArgumentTypeError(f"{path} nor {full_path} are not a valid path")