Argparse type validator for directory arguments. :path: Path of directory. :optname: Name of the option.
(path: str, optname: str)
| 212 | |
| 213 | |
| 214 | def directory_arg(path: str, optname: str) -> str: |
| 215 | """Argparse type validator for directory arguments. |
| 216 | |
| 217 | :path: Path of directory. |
| 218 | :optname: Name of the option. |
| 219 | """ |
| 220 | if not os.path.isdir(path): |
| 221 | raise UsageError(f"{optname} must be a directory, given: {path}") |
| 222 | return path |
| 223 | |
| 224 | |
| 225 | # Plugins that cannot be disabled via "-p no:X" currently. |