Argparse type validator for filename arguments. :path: Path of filename. :optname: Name of the option.
(path: str, optname: str)
| 201 | |
| 202 | |
| 203 | def filename_arg(path: str, optname: str) -> str: |
| 204 | """Argparse type validator for filename arguments. |
| 205 | |
| 206 | :path: Path of filename. |
| 207 | :optname: Name of the option. |
| 208 | """ |
| 209 | if os.path.isdir(path): |
| 210 | raise UsageError(f"{optname} must be a filename, given: {path}") |
| 211 | return path |
| 212 | |
| 213 | |
| 214 | def directory_arg(path: str, optname: str) -> str: |