| 89 | |
| 90 | |
| 91 | class ReadableDirectory(argparse.Action): |
| 92 | def __call__( |
| 93 | self, |
| 94 | parser: argparse.ArgumentParser, |
| 95 | namespace: argparse.Namespace, |
| 96 | values: Any, |
| 97 | option_string: Optional[str] = None, |
| 98 | ) -> None: |
| 99 | prospective_dir = os.path.expanduser(values) |
| 100 | if not os.path.isdir(prospective_dir): |
| 101 | parser.error(f"{prospective_dir} is not a valid path") |
| 102 | if not os.access(prospective_dir, os.R_OK): |
| 103 | parser.error(f"{prospective_dir} is not a readable directory") |
| 104 | setattr(namespace, self.dest, prospective_dir) |
| 105 | |
| 106 | |
| 107 | def generate_cli_parser() -> argparse.ArgumentParser: |
nothing calls this directly
no outgoing calls
no test coverage detected