generated from jCloud/repository-template
Refactor(utils): mark ExistingDirectory and ExistingFile as deprecated #14
@@ -24,10 +24,12 @@ import argparse
|
||||
import pathlib
|
||||
|
||||
def existing_directory(path: str) -> pathlib.Path:
|
||||
try:
|
||||
return pathlib.Path(path)
|
||||
except (FileNotFoundError, NotADirectoryError) as e:
|
||||
raise argparse.ArgumentTypeError(f'{e.filename}{": " + e.args[1] if len(e.args) > 1 else ""}')
|
||||
_path = path
|
||||
path = pathlib.Path(_path)
|
||||
|
jakob.scheid marked this conversation as resolved
Outdated
|
||||
if not path.exists():
|
||||
raise argparse.ArgumentTypeError(f'{_path}: no such file or directory')
|
||||
if not path.is_dir():
|
||||
raise argparse.ArgumentTypeError(f'{_path}: not a directory')
|
||||
|
||||
def main() -> int:
|
||||
argument_parser = argparse.ArgumentParser()
|
||||
|
||||
Reference in new issue
Block a user
There is no check whether the directory exists.