Some Traversables implement ``is_dir()`` to raise an exception (i.e. ``FileNotFoundError``) when the directory doesn't exist. This function wraps that call to always return a boolean and only return True if there's a dir and it exists.
(path: Traversable)
| 116 | |
| 117 | |
| 118 | def _is_present_dir(path: Traversable) -> bool: |
| 119 | """ |
| 120 | Some Traversables implement ``is_dir()`` to raise an |
| 121 | exception (i.e. ``FileNotFoundError``) when the |
| 122 | directory doesn't exist. This function wraps that call |
| 123 | to always return a boolean and only return True |
| 124 | if there's a dir and it exists. |
| 125 | """ |
| 126 | with contextlib.suppress(FileNotFoundError): |
| 127 | return path.is_dir() |
| 128 | return False |
| 129 | |
| 130 | |
| 131 | @functools.singledispatch |